04. Train The Trainers NESTED LOOPS - проблем! Къде ми е грешката?! Благодаря ви!
function solve(input) {
let index = 0;
let n = Number(input[0]);
let presentationCounter = Number(input[1]);
let namePresentation = Number(input[2]);
let averageGradePerPresentation = Number(input[3]);
let sumGrades = 0;
let totalGrades = 0;
let grades = 0;
while (true == "Finish") {
presentationCounter += 1;
for (let i = 0; i <= n; i++) {
sumGrades = input[index];
sumGrades += grades;
index++;
}
if (namePresentation != "Finish") {
averageGradePerPresentation = (sumGrades / n);
}
totalGrades += averageGradePerPresentation;
sumGrades = 0;
namePresentation = input[index];
break;
}
if (namePresentation != "Finish") {
console.log(`${namePresentation} - ${averageGradePerPresentation.toFixed(2)}.`);
}
if (namePresentation == "Finish") {
let totalGradesPrint = totalGrades / presentationCounter;
console.log(`Student's final assessment is ${totalGradesPrint.toFixed(2)}.`); l
}
}