- 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 variableminValue
with the valueusersByDay[currentIndex]
. - Then in the loop, delete console log and add condition
usersByDay[j] < minValue
. - When the condition is met, assign variable
minValue
value 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