Advertisement
Guest User

exam preparation

a guest
Nov 25th, 2019
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let badGradesInput = +input.shift();
  3.     //mnogokratno se chetat
  4.     let taskName = input.shift();
  5.     let grade = +input.shift();
  6.     //
  7.     let badGradesCount = 0;
  8.     let sumGrades = 0;
  9.     let gradesCounter = 0;
  10.     let lastProblem = "";
  11.     let averageGrade = 0;
  12.  
  13.     while (badGradesCount < badGradesInput) {
  14.         let taskName = input.shift();
  15.         let grade = Number(input.shift());
  16.  
  17.     } if (taskName == "Enough") {
  18.         averageGrade = sumGrades / gradesCounter;
  19.         console.log(`Average score : ${averageGrade}`);
  20.  
  21.  
  22.         break;
  23.     } sumGrades += grade;
  24.     ++gradesCounter
  25.     if (grade <= 4) {
  26.         ++badGradesCount
  27.         lastProblem = taskName
  28.     }
  29.     if (badGradesCount == badGradesInput){
  30.         console.log (`You need a break, ${badGradesCount} poor grades.`)
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement