- 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
currentIndexdeclaration, declareminValuewith the valueusersByDay[currentIndex]. - In the loop, remove the console log and add an if statement with the condition
usersByDay[j] < minValue. - If the condition is true, assign the value of
usersByDay[j]tominValue. - 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