Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shopping(input) {
- let budget = Number(input[0]);
- let videoCardCount = Number(input[1]);
- let processorsCount = Number(input[2]);
- let ramMemoryCount = Number(input[3]);
- let totalPrice = 0;
- let videoCardPrice = 250 * videoCardCount;
- let processorsPrice = (videoCardPrice * 0.35) * processorsCount;
- let ramMemoryPrice = (videoCardPrice * 0.10) * ramMemoryCount;
- totalPrice = videoCardPrice + processorsPrice + ramMemoryPrice;
- if (videoCardCount > processorsCount) {
- totalPrice = totalPrice * 0.85;
- if (budget >= totalPrice) {
- console.log(`You have ${(budget - totalPrice).toFixed(2)} leva left!`);
- } else {
- console.log(`Not enough money! You need ${(totalPrice - budget).toFixed(2)} leva more!`);
- }
- }
- }
- shopping(["920.45", "3", "1", "1"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement