Advertisement
mahlichavpm

Untitled

Feb 19th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     let tshirtPrice = Number(input[0]);
  4.     let neededSum = Number(input[1]);
  5.  
  6.     let shortsPrice = tshirtPrice * 0.75;
  7.     let socksPrice = shortsPrice * 0.20;
  8.     let shoesPrice = (shortsPrice + tshirtPrice) * 2;
  9.  
  10.     let sum = tshirtPrice + shortsPrice + socksPrice + shoesPrice;
  11.     let afterDiscount = sum * 0.85;
  12.  
  13.     if (afterDiscount > neededSum) {
  14.         console.log("Yes, he will earn the world-cup replica ball!");
  15.         console.log("His sum is "+ afterDiscount.toFixed(2) +" lv.")
  16.     } else {
  17.         let diff = neededSum - afterDiscount;
  18.         console.log("No, he will not earn the world-cup replica ball.")
  19.         console.log(`He needs ${diff.toFixed(2)} lv. more.`)
  20.     }
  21.  
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement