Untitled

mail@pastecode.io avatar
unknown
javascript
6 months ago
696 B
5
Indexable
Never
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.`);
    }

}
Leave a Comment