Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function smartLilly(args) {
- let washMashine = Number(args[1]);
- let priceGift = Number(args[2]);
- let age = Number(args[0]);
- let birthdayMoney = 0;
- let gifts = 0;
- let bonusMoney = 0;
- for (i = 1; i <= age; i+=2) {
- bonusMoney += 10;
- birthdayMoney += bonusMoney;
- birthdayMoney--;
- }
- for (i = 0; i< age; i+=2) {
- gifts++;
- }
- if(washMashine <= (birthdayMoney + (gifts * priceGift))){
- console.log("Yes! " + (birthdayMoney + (gifts * priceGift) - washMashine).toFixed(2));
- }else if(washMashine > (birthdayMoney + (gifts * priceGift))){
- console.log("No! " + (washMashine - (birthdayMoney + (gifts * priceGift))).toFixed(2));
- }
- }
- smartLilly([10, 170, 6]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement