- script.js
JavaScript
var usersByDay = [4, 2, 1, 3];
console.log(usersByDay);
var currentIndex = 0;
for (var j = currentIndex + 1; j <= usersByDay.length - 1; j++) {
console.log(usersByDay[j]);
}
Result
Goalscompleted
- After the variable
currentIndex, add a variableminValuewith the valueusersByDay[currentIndex]. - Then in the loop, delete console log and add condition
usersByDay[j] < minValue. - When the condition is met, assign variable
minValuevalue of the j-th element of the array. - And in the same place log the following message in the console:
'New minimum element: ' + minValue. - After the loop, log this message in the console:
'Minimum element: ' + minValue.
Comments