Advertisement
Liliana797979

shopping

Dec 22nd, 2020
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shopping(arg1, arg2, arg3, arg4) {
  2.     let budget = Number(arg1);
  3.     let videoCardCount = Number(arg2);
  4.     let processorsCount = Number(arg3);
  5.     let ramMemoryCount = Number(arg4);
  6.     let totalPrice = 0;
  7.  
  8.     if (videoCardCount > processorsCount) {
  9.         let totalSum = totalPrice * 0.85;
  10.  
  11.     } else {
  12.         totalSum;
  13.     }
  14.  
  15.     let videoCardPrice = videoCardCount * 250;
  16.     let processorPrice = processorsCount * (videoCardPrice * 0.35);
  17.     let ramMemoryPrice = ramMemoryCount * (videoCardPrice * 0.1);
  18.     totalSum = videoCardPrice + processorPrice + ramMemoryPrice;
  19.  
  20.     if (budget >= totalSum) {
  21.         console.log(`You have ${(budget - totalSum).toFixed(2)} leva left!`);
  22.  
  23.     } else if (budget < totalSum) {
  24.         console.log(`Not enough money! You need ${(totalSum - budget).toFixed(2)} leva more!`);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement