SHARE
TWEET

Untitled

a guest Feb 15th, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solution(input) {
  2.   let inOfBadGrades = Number(input.shift());
  3.   let countBadGrades = 0;
  4.   let sumGrades = 0;
  5.   let counterForGrades = 0;
  6.   let lastProblem = "";
  7.   let avarageGrade = 0; //средна оценка
  8.   let exellent = false;
  9.   let command = input.shift();
  10.   let grade = Number(input.shift());
  11.  
  12.   while (command !== "Enough") {
  13.        
  14.        
  15.     let nameOfExercise = (command);
  16.     counterForGrades++;
  17.     sumGrades += grade;
  18.     lastProblem = nameOfExercise;
  19.     command = input.shift();
  20.     grade = Number(input.shift());
  21.  
  22.     if (grade <= 4) {
  23.       countBadGrades++
  24.   }
  25.  
  26. avarageGrade = sumGrades / counterForGrades;
  27.   }
  28.   if(command == "Enough"){
  29.     console.log(`Average score: ${avarageGrade}`);
  30.         console.log(`Number of problems: ${counterForGrades}`);
  31.         console.log(`Last problem: ${lastProblem}`);
  32.   }
  33.   else if(inOfBadGrades<=counterForGrades){
  34.     console.log(`You need a break, ${countBadGrades} poor grades.`);
  35.   }
  36. }
  37. solution([
  38.   "3",
  39.   "Money",
  40.   "6",
  41.   "Story",
  42.   "4",
  43.   "Spring Time",
  44.   "5",
  45.   "Bus",
  46.   "6",
  47.   "Enough"
  48. ])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top