Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- const budget = (input[0]);
- const videoCardsAmount = (input[1]);
- const processorsAmount = (input[2]);
- const ramsAmount = (input[3]);
- let videoSum = videoCardsAmount * 250;
- let processorPrice = videoSum * 0.35;
- let ram = videoSum * 0.10;
- let processorSum = processorPrice * processorsAmount;
- let ramSum = ramsAmount * ram;
- let total = videoSum + processorPrice + ramSum;
- if(videoCardsAmount > processorsAmount){
- total = total * 0.85;
- }
- let diff = Math.abs(budget - total);
- if (total <= budget) {
- console.log(`You have ${diff.toFixed(2)} leva left!`)
- } else {
- console.log(`Not enough money! You need ${diff.toFixed(2)} leva more!`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement