HTML Academy
Finishing the traffic analyzer
Arrays4/30
Back to the list of tasks
  • 1. Little Muffin and Big Data
  • 2. Average value
  • 3. Finishing the traffic analyzer
  • 4. New data
  • 5. A lot of data? An array!
  • 6. Reading an array element by index
  • 7. Using a variable as an index
  • 8. Array length
  • 9. Let’s hit arrays with loops!
  • 10. Summation in the loop
  • 11. Finishing refactoring
  • 12. One small analytical investigation
  • 13. Writing to an array by index
  • 14. The murderer is a butler!
  • 15. Summary of “Arrays”. Part 1
  • 16. Fifth program: Beginner decryptor
  • 17. Vague suspicions
  • 18. Swapping the elements
  • 19. Looking for the minimum element
  • 20. The minimum element is found!
  • 21. Starting sorting
  • 22. Continue sorting
  • 23. Finish sorting
  • 24. Testing the sorting
  • 25. Median of an odd number of elements
  • 26. Median of an even number of elements
  • 27. Green light
  • 28. The murderer is the butler, again!
  • 29. Summary of “Arrays”. Part 2
  • 30. Sixth program: Long jump records
A lot of data? An array!
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

New data

  • Tr-r-r-raffic is so-so?! Who do you think you are?! Fluffs up his tail
  • But, boss, it’s statistics for just three days; it may be inaccurate.
  • And how can you make it accurate? The tail is slowly coming down
  • We need more data. Wait for one month.
  • This is traffic for one more day. Analyze it right meow!

The boss’ feelings were hurt by the recommendation to try harder with the blog. Plus, yesterday he released a very successful new video about how to ambush your owner and attack his feet using different techniques.

He calmed down (for now) after he heard about the lack of data. But he immediately sent the data for yesterday and he demands that they be added to the program. And this is to our advantage. After all, a successful video means good traffic. And this will have a positive effect on the average traffic.

The boss will be delighted to see good results, and this will give us time to prepare him emotionally for possibly bad traffic results for the month.

Your urgent task is to add new data to the program. For this you need not only to add a variable with traffic for yesterday (in the program and on the graph), but also update the formula for calculating the average. In the formula, add one more summand to the sum and also increase the divisor from three to four.

Comments

  • script.js
JavaScript
var expectedUsers = 1000; var firstDayUsers = 812; var secondDayUsers = 1360; var thirdDayUsers = 657; // Drawing the traffic graph muffin.plot(firstDayUsers, secondDayUsers, thirdDayUsers, expectedUsers); // Calculating the average traffic value var averageUsers = (firstDayUsers + secondDayUsers + thirdDayUsers) / 3; 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.'); }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

Console

The code has changed, click “Run” or turn autorun on.

Result

Goalscompleted
  1. On the line after the thirdDayUsers declaration, declare fourthDayUsers with the value 1247.
  2. Add fourthDayUsers after thirdDayUsers in the arguments passed to muffin.plot().
  3. Change average value calculation. Add fourthDayUsers as the last summand and change the divisor to 4.

Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2026

VISAMastercard

Log in

or

Forgot your password?

Sign up

Sign up

or
Log in

Restore access

Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

Forgot to connect your email to the profile? Email us and we’ll help.