- script.js
JavaScript
var usersByDay = [1, 2, 3, 4, 5];
console.log(usersByDay);
Result
Goalscompleted
- At the end of the program, add a check for an odd number of elements in the array:
usersByDay.length % 2 !== 0. - If the condition is met, add a variable
medianIndexwith value(usersByDay.length - 1) / 2. - Log this variable in the console.
- In the same condition branch, add variable
medianwith valueusersByDay[medianIndex]. - Log it in the console as well.

Comments