Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oscars(input){
- let actorName = input.shift();
- let score = Number(input.shift());
- let jury = Number(input.shift());
- let isEnough = false;
- let endLoop = false;
- for (let judge = 1; judge <= jury; judge++){
- let judgeName = input.shift();
- let judgeScore = Number(input.shift());
- let judgeNameIndex = judgeName.length;
- let finalJudgeScore = judgeNameIndex * judgeScore / 2;
- score += finalJudgeScore;
- if (score >= 1250.5){
- isEnough = true;
- break;
- }
- if (judge === jury){
- endLoop = true;
- }
- }
- if (isEnough){
- console.log(`Congratulations, ${actorName} got a nominee for leading role with ${score.toFixed(1)}!`);
- }
- else if (endLoop) {
- console.log(`Sorry, ${actorName} you need ${(1250.5 - score).toFixed(1)} more!`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement