Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let tshirtPrice = Number(input[0]);
- let neededSum = Number(input[1]);
- let shortsPrice = tshirtPrice * 0.75;
- let socksPrice = shortsPrice * 0.20;
- let shoesPrice = (shortsPrice + tshirtPrice) * 2;
- let sum = tshirtPrice + shortsPrice + socksPrice + shoesPrice;
- let afterDiscount = sum * 0.85;
- if (afterDiscount > neededSum) {
- console.log("Yes, he will earn the world-cup replica ball!");
- console.log("His sum is "+ afterDiscount.toFixed(2) +" lv.")
- } else {
- let diff = neededSum - afterDiscount;
- console.log("No, he will not earn the world-cup replica ball.")
- console.log(`He needs ${diff.toFixed(2)} lv. more.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement