krustev_84

Untitled

Mar 15th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. function trainTheTrainers(input) {
  2. let trainers = input.shift();
  3. let problem = input.shift();
  4.  
  5. let averageGrades = 0;
  6. let totalAverageGrades = 0;
  7. let counter = 0;
  8.  
  9. while (problem !== "Finish") {
  10. let commadnCounter = 0;
  11. let sumGrades = 0;
  12. while (commadnCounter !== trainers) {
  13. commadnCounter++;
  14. command = input.shift();
  15. sumGrades += command;
  16. }
  17.  
  18. counter++;
  19. averageGrades = sumGrades / commadnCounter;
  20. console.log(`${problem} - ${averageGrades.toFixed(2)}.`);
  21. problem = input.shift();
  22. totalAverageGrades += averageGrades;
  23. }
  24.  
  25. console.log(
  26. `Student's final assessment is ${(totalAverageGrades / counter).toFixed(
  27. 2
  28. )}.`
  29. );
  30. }
  31. trainTheTrainers([
  32. 2,
  33. "Objects and Classes",
  34. 5.77,
  35. 4.23,
  36. "Dictionaries",
  37. 4.62,
  38. 5.02,
  39. "RegEx",
  40. 2.88,
  41. 3.42,
  42. "Finish"
  43. ]);
Advertisement
Add Comment
Please, Sign In to add comment