Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shopping(input) {
- let peturBuget = Number(input[0]);
- let videoCards = Number(input[1]);
- let processors = Number(input[2]);
- let ram = Number(input[3]);
- // let videoCardSum = videoCards * 250;
- // let processorPrice = videoCardSum * 0.35;
- // let processorSum = processors * processorPrice;
- // let ramPrice = videoCardSum * 0.10;
- // let ramSum = ramPrice * ram;
- let videoCardSum = videoCards * 250;
- let processorPrice = (videoCardSum * 0.35) * processors;
- let ramPrice = (videoCardSum * 0.1) * ram;
- let totalPrice = videoCardSum + processorPrice + ramPrice
- let totalSum = videoCardSum + processorPrice + ramPrice;
- if (videoCards > processors) {
- totalSum = totalSum * 0.85;
- }
- let diff = Math.abs(peturBuget - totalSum);
- if (totalSum <= peturBuget){
- 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