Нужда от помощ за задача Easter Competition JS Programming basic
Много ви моля колеги, ако някой я е решил да ми покаже решението, защото съм зациклила и не мога да измисля как да я реша. До тук съм стигнала, ама не е много ок....
function easter(input) {
let index = 0;
let easterBread = Number(input[index]);
index++
let command = input[index];
index++
let points = 0
let localPoints = 0;
let counter = 0;
let bestChef = '';
let bestScore = 0;
for (let i = 0; i < easterBread; i++) {
counter++
points = 0;
let chef = command
command = input[index];
index++;
while (command !== 'Stop') {
localPoints = Number(command);
points += localPoints
command = input[index];
index++
}
if (points >= bestScore) {
bestScore = points;
bestChef = chef
}
if (counter === 1) {
console.log(`${chef} has ${points} points.`);
console.log(`${chef} is the new number 1!`);
} else {
console.log(`${chef} has ${points} points.`)
}
command = input[index];
index++;
}
console.log(`${bestChef} won competition with ${bestScore} points!`);
}
Best,