HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <ul><li>script.js</li>
1 <ul><li>script.js</li>
2 </ul><p>JavaScript</p>
2 </ul><p>JavaScript</p>
3 <p>var usersByDay = [1, 2, 3, 4, 5, 6]; console.log(usersByDay); if (usersByDay.length % 2 !== 0) { var medianIndex = (usersByDay.length - 1) / 2; console.log(medianIndex); var median = usersByDay[medianIndex]; console.log(median); }</p>
3 <p>var usersByDay = [1, 2, 3, 4, 5, 6]; console.log(usersByDay); if (usersByDay.length % 2 !== 0) { var medianIndex = (usersByDay.length - 1) / 2; console.log(medianIndex); var median = usersByDay[medianIndex]; console.log(median); }</p>
4 <p>Thanks! We’ll fix everything at once!</p>
4 <p>Thanks! We’ll fix everything at once!</p>
5 <h2>Result</h2>
5 <h2>Result</h2>
6 <ol><li>In the alternative branch of the condition, add the variable leftIndex with the value usersByDay.length / 2 - 1.</li>
6 <ol><li>In the alternative branch of the condition, add the variable leftIndex with the value usersByDay.length / 2 - 1.</li>
7 <li>And variable rightIndex with value usersByDay.length / 2.</li>
7 <li>And variable rightIndex with value usersByDay.length / 2.</li>
8 <li>Log both variables in the console.</li>
8 <li>Log both variables in the console.</li>
9 <li>In the same condition branch, add variable median with value (usersByDay[leftIndex] + usersByDay[rightIndex]) / 2.</li>
9 <li>In the same condition branch, add variable median with value (usersByDay[leftIndex] + usersByDay[rightIndex]) / 2.</li>
10 <li>Log it in the console as well.</li>
10 <li>Log it in the console as well.</li>
11 </ol>
11 </ol>