Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shopping(arg1, arg2, arg3, arg4) {
- let budget = Number(arg1);
- let videoCardCount = Number(arg2);
- let processorsCount = Number(arg3);
- let ramMemoryCount = Number(arg4);
- let totalPrice = 0;
- if (videoCardCount > processorsCount) {
- let totalSum = totalPrice * 0.85;
- } else {
- totalSum;
- }
- let videoCardPrice = videoCardCount * 250;
- let processorPrice = processorsCount * (videoCardPrice * 0.35);
- let ramMemoryPrice = ramMemoryCount * (videoCardPrice * 0.1);
- totalSum = videoCardPrice + processorPrice + ramMemoryPrice;
- if (budget >= totalSum) {
- console.log(`You have ${(budget - totalSum).toFixed(2)} leva left!`);
- } else if (budget < totalSum) {
- console.log(`Not enough money! You need ${(totalSum - budget).toFixed(2)} leva more!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement