Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let actorName = input[0];
- let academyPoints = +input[1];
- let raters = +input[2];
- let raterName = "";
- let currentPoints = 0;
- let points = academyPoints;
- let target = 1250.5;
- let end = raters * 3 - 2;
- let diff = 0;
- for (i = 3; i <= i + 3; i++, i++) {
- raterName = input[i];
- currentPoints = +input[i + 1];
- if (raterName == "") {
- break;
- }
- if (raterName !== "") {
- points += (raterName.length * currentPoints) / 2;
- }
- diff = target - points;
- if (points >= target) {
- output = `Congratulations, ${actorName} got a nominee for leading role with ${points.toFixed(
- 1
- )}!`;
- break;
- } else {
- output = `Sorry, ${actorName} you need ${diff.toFixed(1)} more!`;
- }
- }
- console.log(output);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement