Advertisement
Didart

Bonus Score

Mar 7th, 2022
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bonusScore(input) {
  2.     let digit = Number(input[0]);
  3.     let bonusScore = 0.0;
  4.  
  5.     if (digit <= 100) {
  6.         bonusScore += 5;
  7.     } else if (digit > 1000) {
  8.         bonusScore = digit * 0.1;
  9.     } else {
  10.         bonusScore = digit * 0.2;
  11.     }
  12.  
  13.     if (digit % 2 == 0) {
  14.         bonusScore += 1;
  15.     } else if (digit % 10 == 5) {
  16.         bonusScore += 2;
  17.     }
  18.  
  19.     console.log(bonusScore);
  20.     console.log(digit + bonusScore);
  21. }
  22. bonusScore(["2703"])
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement