YavorJS

Bonus Points JS

May 30th, 2016
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. function solve(arr) {
  2. var points = Number(arr[0]);
  3. var bonusPoints = 0;
  4. var allPoints = 0;
  5.  
  6. if (points <= 100) {
  7. bonusPoints = 5;
  8. allPoints = points + bonusPoints;
  9. }
  10. else if (points > 100 && points <= 1000) {
  11. bonusPoints = points * 20 / 100;
  12. allPoints = points + bonusPoints;
  13. }
  14. else if (points > 1000) {
  15. bonusPoints = points * 10 / 100;
  16. allPoints = points + bonusPoints;
  17. }
  18.  
  19. if (points % 2 == 0) {
  20. bonusPoints++;
  21. allPoints++;
  22. }
  23.  
  24. if (points % 10 == 5) {
  25. bonusPoints = bonusPoints + 2;
  26. allPoints = allPoints + 2;
  27. }
  28.  
  29. console.log(bonusPoints);
  30. console.log(allPoints);
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment