Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oscars(input) {
- let index = 0;
- let actorName = input[index]; //index 0
- index++;
- let totalPoints = Number(input[index]); //index 1
- index++;
- let judgeCount = Number(input[index]); //index 2
- index++; //index 3 next line
- let judgePoints = 0;
- let notNominee = true;
- for (let i = 0; i < judgeCount; i++) {
- let currentJudgeName = input[index]; //index 3
- index++;
- let currentJudgePoints = Number(input[index]); //index 4
- index++;
- judgePoints = (currentJudgeName.length * currentJudgePoints) / 2;
- totalPoints += judgePoints;
- if (totalPoints >= 1250.5) {
- notNominee = false;
- console.log(`Congratulations, ${actorName} got a nominee for leading role with ${totalPoints.toFixed(1)}!`);
- break;
- }
- }
- let diff = 1250.5 - totalPoints;
- if (notNominee) {
- console.log(`Sorry, ${actorName} you need ${diff.toFixed(1)} more!`);
- }
- }
- oscars(["Sandra Bullock", "340", "5", "Robert De Niro", "50", "Julia Roberts", "40.5", "Daniel Day-Lewis", "39.4", "Nicolas Cage", "29.9", "Stoyanka Mutafova", "33"]);
Add Comment
Please, Sign In to add comment