Advertisement
SIRAKOV4444

Untitled

Mar 21st, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. function Petya(input) {
  2. let vacation = input.shift();
  3. let puzzels=input.shift();//price 2.60лв
  4. let dolls=input.shift();//3lv
  5. let teddys=input.shift();//4.10lv
  6. let minis=input.shift();//8.20лв
  7. let trucks=input.shift();//2лв
  8.  
  9. let totalPrice=(puzzels*2.60)+
  10. (dolls*3)+(teddys*4.10)+(minis*8.20)
  11. +(trucks*2);
  12.  
  13. let count=(puzzels+dolls+teddys
  14. +minis+trucks);
  15.  
  16. if(count<50){
  17. totalPrice*=1;
  18. }else{
  19. totalPrice*=0.75;
  20. }
  21.  
  22. totalPrice*=0.9;
  23.  
  24. if(totalPrice>=vacation){
  25. console.log("Yes! "+((totalPrice-
  26. vacation).toFixed(2))+" lv left.");
  27. }else{
  28. console.log( "Not enough money! "+
  29. ((vacation-totalPrice).toFixed(2))
  30. +" lv needed.");
  31. }
  32. }
  33. Petya([320,
  34. 8,
  35. 2,
  36. 5,
  37. 5,
  38. 1]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement