Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function lily(input) {
- let age = +(input.shift());
- let washingMashinePrice = +(input.shift());
- let toysPrice = +(input.shift());
- let saves = 0;
- let money = 0;
- let countToys = 0;
- for (let i = 1; i <= age; i++) {
- if (i % 2 == 0) {
- money += (10 * i / 2) - 1;
- } else {
- countToys++;
- }
- }
- saves = money + countToys * toysPrice;
- if (saves >= washingMashinePrice) {
- console.log(`Yes! ${(saves - washingMashinePrice).toFixed(2)}`);
- } else {
- console.log(`No! ${(washingMashinePrice - saves).toFixed(2)}`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment