Проблем с 02. Exam Preparation While-Loop - Exercise
Здравейте, моля за малко помощ с тази задача. Все още while-loop задачите са ми тъмна индия. Благодаря! Линк към задачката ⦁ Подготовка за изпит
function exam(input) {
let inputOfbadGrades = Number(input.shift());
let countForBadGrades=0;
let sumGrades =0;
let counterForGrades=0;
let lastProblem='';
while (countForBadGrades < inputOfbadGrades) {
let nameOfExercise=input.shift();
let grade=Number(input.shift());
if (nameOfExercise=='Enough'){
sumGrades = sumGrades/counterForGrades;
console.log(`Average score: ${sumGrades}\nNumber of problems: ${counterForGrades}\nLast problem: ${lastProblem}`);
}
if (grade <= 4){
countForBadGrades++
lastProblem=nameOfExercise;
}
counterForGrades++
sumGrades++
}
if(counterForGrades==inputOfbadGrades){
console.log(`You need a break, ${countForBadGrades} poor grades.`);
}
}
exam ([3,
'Money',
6,
'Story',
4,
'Spring Time',
5,
'Bus',
6,
'Enough'])