Advertisement
Liliana797979

viarno reshenie train the trainers

Feb 16th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function trainTheTrainers(input) {
  2.     let index = 0;
  3.     let juryCount = Number(input[index++]);
  4.     let presentationsCount = 0;
  5.     let averagesSum = 0;
  6.  
  7.     let presentation = input[index++];
  8.  
  9.     while (presentation !== "Finish") {
  10.         let presentationSum = 0;
  11.  
  12.         for (let i = 0; i < juryCount; i++) {
  13.             let currentGrade = Number(input[index++]);
  14.             presentationSum += currentGrade;
  15.  
  16.         }
  17.  
  18.         let presentationAverage = presentationSum / juryCount;
  19.  
  20.         console.log(`${presentation} - ${presentationAverage.toFixed(2)}.`);
  21.  
  22.         averagesSum += presentationAverage;
  23.  
  24.         presentationsCount++;
  25.  
  26.         presentation = input[index++];
  27.  
  28.     }
  29.     console.log(`Student's final assessment is ${(averagesSum / presentationsCount).toFixed(2)}.`);
  30. }
  31.  
  32. trainTheTrainers(["2",
  33.    "While-Loop",
  34.    "6.00",
  35.    "5.50",
  36.    "For-Loop",
  37.    "5.84",
  38.    "5.66",
  39.    "Finish"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement