Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function oscars(input) {
- let index = 0;
- let name = input[index];
- index++;
- let points = Number(input[index]);
- index++;
- let evaluators = Number(input[index]);
- index++;
- let neededPoints = 1250.50;
- let totalPoints = points;
- for (let i = 0; i < evaluators; i++) {
- let currentName = input[index];
- index++;
- let currentPoints = Number(input[index]);
- index++;
- totalPoints += ((currentName.length * currentPoints) / 2);
- if (totalPoints >= neededPoints) {
- console.log(`Congratulations, ${name} got a nominee for leading role with ${totalPoints.toFixed(1)}!`);
- break;
- }
- }
- if (totalPoints < neededPoints) {
- let diff = neededPoints - totalPoints;
- console.log(`Sorry, ${name} you need ${diff.toFixed(1)} more!`);
- }
- }
Add Comment
Please, Sign In to add comment