Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function toyShop(input) {
- let amount = parseFloat(input[0]);
- let puzzles = parseInt(input[1]);
- let dolls = parseInt(input[2]);
- let bears = parseInt(input[3]);
- let minions = parseInt(input[4]);
- let trucks = parseInt(input[5]);
- let puzzlesPrice = puzzles * 2.6;
- let dollsPrice = dolls * 3;
- let bearsPrice = bears * 4.1;
- let minionsPrice = minions * 8.2;
- let trucksPrice = trucks * 2;
- let toys = puzzles + dolls + bears + minions + trucks;
- let price = puzzlesPrice + dollsPrice + bearsPrice + minionsPrice + trucksPrice;
- if (toys >= 50){
- price *= 0.75;
- }
- price *= 0.9;
- if (price >= amount){
- console.log(`Yes! ${(price - amount).toFixed(2)} lv left.`);
- }else{
- console.log(`Not enough money! ${(amount - price).toFixed(2)} lv needed.`);
- }
- }
Add Comment
Please, Sign In to add comment