MartenBG

Untitled

Feb 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. function lily(input) {
  2. let age = +(input.shift());
  3. let washingMashinePrice = +(input.shift());
  4. let toysPrice = +(input.shift());
  5. let money = 0;
  6. let countToys = 0;
  7. for (let i = 1; i <= age; i++) {
  8. if (i % 2 == 0) {
  9. money += (10 * i / 2) - 1;
  10. } else {
  11. countToys++;
  12. }
  13. }
  14. saves = money + countToys * toysPrice;
  15. if (saves >= washingMashinePrice) {
  16. console.log(`Yes! ${(saves - washingMashinePrice).toFixed(2)}`);
  17. } else {
  18. console.log(`No! ${(washingMashinePrice - saves).toFixed(2)}`);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment