• Theory
  • Theory

Sixth program: Long jump records

After a couple of meowtalities, the popularity growth of the video blog was resumed, and the updated version of the analyzer program eliminated all the cheating. Now Muffin can devote himself to his favorite thing to do.

Every year the boss participates in all-cat competitions in long jumps from the wall. Competitions are held among the best cats in the country and require serious preparation.

Selection for competitions is tough, it’s hard to qualify for them, and that’s Muffin needs a program that runs qualification rounds according to the rules of the championship. Anyway, here is the technical assignment:

Meow! I train regularly and I want to understand if I will qualify.

During the training I do a few jumps and collect the lengths of the jumps into the array attempts.

The qualification value is stored in the qualificationDistance variable.

The program must choose the three best jumps, calculate the average value of these three jumps and write it into the averageBest variable.

If the average of the best three jumps is greater than the qualification value, then I passed the qualification and variable qualified must contain true. If qualification round is not passed, then qualified must contain false.

You can find the best three values ​​in different ways. You can sort the array in ascending order (you already know how to do it) and take the last three elements (you practiced that as well).

You can test yourself and try to sort the array in descending order. Then after the sorting, the best three values ​​will be at the beginning of the array.

When you are done, press Hey boss, here’s your program!

  • index.html
HTML
HTML

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Granny Muffin

Easy there, pal!

To access the Arrays challenges in the JavaScript programming, you need to sign up and subscribe first.