Interactive online courses HTML Academy
2026-03-09 14:12 Diff
  • script.js

JavaScript

var expectedUsers = 1000; var usersByDay = [812, 1360, 657, 1247]; // Drawing the traffic graph muffin.plot(usersByDay, expectedUsers); for (var i = 0; i <= usersByDay.length - 1; i++) { console.log(usersByDay[i]); } // Calculating the average traffic value var averageUsers = 0; console.log('Average traffic: ' + averageUsers); if (averageUsers > expectedUsers) { console.log('Traffic is amazing. Keep up the good work!'); } else { console.log('Traffic is so-so. You need to try harder!'); }

Thanks! We’ll fix everything at once!

Result

  1. Before the loop, add a variable totalUsers with a zero value.
  2. Inside the loop, remove console log and increase the value of the variable totalUsers by usersByDay[i].
  3. Inside the loop, log the variable totalUsers in the console.