Advertisement
Liliana797979

moeto viarno reshenie shopping

Feb 18th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function shopping(input) {
  2.     let budget = Number(input[0]);
  3.     let videoCardCount = Number(input[1]);
  4.     let processorsCount = Number(input[2]);
  5.     let ramMemoryCount = Number(input[3]);
  6.     let totalPrice = 0;
  7.  
  8.     let videoCardPrice = 250 * videoCardCount;
  9.     let processorsPrice = (videoCardPrice * 0.35) * processorsCount;
  10.     let ramMemoryPrice = (videoCardPrice * 0.10) * ramMemoryCount;
  11.    
  12.  
  13.     totalPrice = videoCardPrice + processorsPrice + ramMemoryPrice;
  14.  
  15.     if (videoCardCount > processorsCount) {
  16.         totalPrice = totalPrice * 0.85;
  17.     }
  18.  
  19.         if (budget >= totalPrice) {
  20.             console.log(`You have ${(budget - totalPrice).toFixed(2)} leva left!`);
  21.         } else {
  22.             console.log(`Not enough money! You need ${(totalPrice - budget).toFixed(2)} leva more!`);
  23.         }
  24.     }
  25.  
  26.  
  27. shopping(["920.45", "3", "1", "1"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement