- 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 true, declare
medianIndexwith the value(usersByDay.length - 1) / 2. - Log this variable in the console.
- In the same if block, declare
medianwith the valueusersByDay[medianIndex]. - Log it in the console as well.

Comments