Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function easterCompetition(input) {
- let baker_num = Number(input.shift());
- let bakerWin = "";
- let maxPoint = 0;
- for (let i = 0; i < baker_num; i++) {
- let baker = input.shift();
- let points = 0;
- while (true) {
- let info = input.shift();
- if (info === "Stop") {
- break;
- }
- points += Number(info);
- }
- if (maxPoint < points) {
- maxPoint = points;
- bakerWin = baker;
- console.log(`${bakerWin} has ${maxPoint} points.`);
- console.log(`${bakerWin} is the new number 1!`);
- } else {
- console.log(`${baker} has ${points} points.`);
- }
- }
- console.log(`${bakerWin} won competition with ${maxPoint} points!`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement