Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Petya(input) {
- let vacation = input.shift();
- let puzzels=input.shift();//price 2.60лв
- let dolls=input.shift();//3lv
- let teddys=input.shift();//4.10lv
- let minis=input.shift();//8.20лв
- let trucks=input.shift();//2лв
- let totalPrice=(puzzels*2.60)+
- (dolls*3)+(teddys*4.10)+(minis*8.20)
- +(trucks*2);
- let count=(puzzels+dolls+teddys
- +minis+trucks);
- if(count<50){
- totalPrice*=1;
- }else{
- totalPrice*=0.75;
- }
- totalPrice*=0.9;
- if(totalPrice>=vacation){
- console.log("Yes! "+((totalPrice-
- vacation).toFixed(2))+" lv left.");
- }else{
- console.log( "Not enough money! "+
- ((vacation-totalPrice).toFixed(2))
- +" lv needed.");
- }
- }
- Petya([320,
- 8,
- 2,
- 5,
- 5,
- 1]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement