Advertisement
Spocoman

Bonus Score

Jan 4th, 2022 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bonusScore(input) {
  2.     let number = Number(input);
  3.     let bonus = 0.0;
  4.  
  5.     if (number <= 100) {
  6.         bonus = 5;
  7.     } else if (number > 1000) {
  8.         bonus = number * 0.1;
  9.     } else {
  10.         bonus = number * 0.2;
  11.     }
  12.     if (number % 2 === 0) {
  13.         bonus = bonus + 1;
  14.     } else if (number % 10 === 5) {
  15.         bonus = bonus + 2;
  16.     }
  17.     console.log(bonus);
  18.     console.log(number + bonus);
  19. }
  20.  
  21.  
  22. Taрикатско решение:
  23.  
  24. function bonusScore(input) {
  25.     let number = Number(input);
  26.     let bonus = 5.0;
  27.  
  28.     if (number > 1000) {
  29.         bonus = number * 0.1;
  30.     } else if (number > 100) {
  31.         bonus = number * 0.2;
  32.     }
  33.     if (number % 2 === 0) {
  34.         bonus = bonus + 1;
  35.     } else if (number % 10 === 5) {
  36.         bonus = bonus + 2;
  37.     }
  38.     console.log(`${bonus}\n${number + bonus}`);
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement