Untitled
unknown
javascript
2 years ago
696 B
14
Indexable
function toyshop(input) {
let price = Number(input[1] * 2.60 + input[2] * 3 + input[3] * 4.10 + input[4] * 8.20 + input[5] * 2);
let toys = Number(input[1] + input[2] + input[3] + input[4] + input[5]);
if(toys >= 50) {
price = price - (price * 0.25)
} else {
price = price
}
let finalPrice = price - (price * 0.10);
let moneyLeft = finalPrice - Number(input[0]);
let moneyNeeded = Number(input[0]) - Number(finalPrice);
if (finalPrice > Number(input[0])) {
console.log(`Yes! ${moneyLeft.toFixed(2)} lv left.`);
} else {
console.log(`Not enough money! ${moneyNeeded.toFixed(2)} lv needed.`);
}
}Editor is loading...
Leave a Comment