Advertisement
mahlichavpm

Untitled

Jan 22nd, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     const budget = (input[0]);
  4.     const videoCardsAmount = (input[1]);
  5.     const processorsAmount = (input[2]);
  6.     const ramsAmount = (input[3]);
  7.  
  8.     let videoSum = videoCardsAmount * 250;
  9.     let processorPrice = videoSum * 0.35;
  10.     let ram = videoSum * 0.10;
  11.  
  12.     let processorSum = processorPrice * processorsAmount;
  13.     let ramSum = ramsAmount * ram;
  14.  
  15.     let total = videoSum + processorPrice + ramSum;
  16.  
  17.     if(videoCardsAmount > processorsAmount){
  18.         total = total * 0.85;
  19.     }
  20.  
  21.     let diff = Math.abs(budget - total);
  22.  
  23.   if (total <= budget) {
  24.         console.log(`You have ${diff.toFixed(2)} leva left!`)
  25.     } else {
  26.         console.log(`Not enough money! You need ${diff.toFixed(2)} leva more!`)
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement