Advertisement
Liliana797979

viarno reshenie smart lili / clever lili

Feb 17th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function smartLili(input) {
  2.     let age = Number(input[0]);
  3.     let washingMachinePrice = Number(input[1]);
  4.     let toyPrice = Number(input[2]);
  5.  
  6.     let sum = 0;
  7.     let toyCount = 0;
  8.     let moneyCount = 0;
  9.     let birthdayCount = 10;
  10.  
  11.     for (i = 1; i <= age; i++) {
  12.         if (i % 2 === 0) {
  13.             moneyCount += birthdayCount;
  14.             moneyCount = moneyCount - 1;
  15.             birthdayCount += 10;
  16.         } else {
  17.             toyCount++;
  18.         }
  19.     }
  20.     sum = toyCount * toyPrice + moneyCount;
  21.     if (sum >= washingMachinePrice) {
  22.         console.log(`Yes! ${(sum - washingMachinePrice).toFixed(2)}`);
  23.     } else {
  24.         console.log(`No! ${(washingMachinePrice - sum).toFixed(2)}`);
  25.     }
  26. }
  27.  
  28. smartLili(["21", "1570.98", "3"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement