HTML Academy
Average value
Arrays3/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 from an array using index
  • 7. Variable as 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
New data
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Finishing the traffic analyzer

The program works, all we have to do is make the interface friendlier and add recommendations for Muffin.

But first, indicate the value that is logged in the console. Muffin should be able see that it is the average value, and not something else.

Then you need to compare the average value with the expected one and show Muffin the recommendation. If the traffic is good (the average value is greater than the expected one), then cheer the cat up, if not, ask him to work harder and start putting out better content.

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(averageUsers);

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

Complete the program.

  1. Add a hint to the average value log in the console: 'Average traffic: ' + averageUsers.
  2. At the end of the program, add a check to make sure that the average value is greater than the expected one.
  3. If the condition is met, log the message in the console 'Traffic is amazing. Keep up the good work!'.
  4. Otherwise, log the following message in the console 'Traffic is so-so. You need to work harder!'.

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

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.