-Enigmos-

braceletStand.js

Oct 25th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function braceletStand(input) {
  2.     let index = 0;
  3.     let pocketCash = Number(input[index]);
  4.     index++;
  5.     let earnedCash = Number(input[index]);
  6.     index++;
  7.     let expenses = Number(input[index]);
  8.     index++;
  9.     let giftPrice = Number(input[index]);
  10.     index++;
  11.     let days = 5;
  12.  
  13.     let savings = (days * pocketCash) + (days * earnedCash) - expenses;
  14.     if (savings >= giftPrice) {
  15.         console.log(`Profit: ${savings.toFixed(2)} BGN, the gift has been purchased.`);
  16.     } else {
  17.         console.log(`Insufficient money: ${(giftPrice - savings).toFixed(2)} BGN.`);
  18.     }
  19. }
  20.  
  21. braceletStand(["5.12", "32.05", "15", "150"]);
Advertisement
Add Comment
Please, Sign In to add comment