function solve(input) {
    let totalPrice = 0;
    let customer = input.pop();

    for (let price of input) {
        if (price >= 0) {
            let currentPrice = Number(price);
            totalPrice += currentPrice;

        } else if (price < 0) {
            console.log(`Invalid price!`);
        }
    }
    
    let finalPrice = 0;

    if (customer === 'special') {
        finalPrice = totalPrice + (totalPrice * 0.20);
        finalPrice -= finalPrice * 0.10;
    } else {
        finalPrice = totalPrice + (totalPrice * 0.20);
    }

    if (totalPrice > 0) {
        console.log(`Congratulations you've just bought a new computer!`);
        console.log(`Price without taxes: ${totalPrice.toFixed(2)}$`);
        console.log(`Taxes: ${(totalPrice * 0.20).toFixed(2)}$`);
        console.log(`-----------`);
        console.log(`Total price: ${finalPrice.toFixed(2)}$`);

    } else {
        console.log('Invalid order!');
    }

}
// Note: All prices should be displayed to the second digit after the decimal point! The discount is applied only on the total price. Discount is only applicable to the final price!
All prices should be displayed to the second digit after the decimal point. The discount is applied only on the total price. Discount is only applicable to the final price!
All prices should be displayed to the second digit after the decimal point . The discount is applied only on the total price . Discount is only applicable to the final price!
function solve(input) {
    let totalPrice = 0;
    let customer = input.pop();
    for (let price of input) {
        if (price >= 0) {
            let currentPrice = Number(price);
            totalPrice += currentPrice;
        } else if (price < 0) {
            console.log(`Invalid price!`);
        }
    }
    let finalPrice = 0;
    if (customer === 'special') {
        finalPrice = totalPrice + (totalPrice * 0.20);
        finalPrice -= finalPrice * 0.10;
    } else {
        finalPrice = totalPrice + (totalPrice * 0.20);
    }
    if (totalPrice > 0) {
        console.log(`Congratulations you've just bought a new computer!`);
        console.log(`Price without taxes: ${totalPrice.toFixed(2)}$`);
        console.log(`Taxes: ${(totalPrice * 0.20).toFixed(2)}$`);
        console.log(`-----------`);
        console.log(`Total price: ${finalPrice.toFixed(2)}$`);
    } else {
        console.log('Invalid order!');
    }
}
function solve ( input ) { let totalPrice = 0 ; let customer = input . pop ( ) ; for ( let price of input ) { if ( price >= 0 ) { let currentPrice = Number ( price ) ; totalPrice += currentPrice ; } else if ( price < 0 ) { console . log ( ` ` ) ; } } let finalPrice = 0 ; if ( customer === 'special' ) { finalPrice = totalPrice + ( totalPrice * 0.20 ) ; finalPrice -= finalPrice * 0.10 ; } else { finalPrice = totalPrice + ( totalPrice * 0.20 ) ; } if ( totalPrice > 0 ) { console . log ( ` ` ) ; console . log ( ` ${ totalPrice . toFixed ( 2 ) } ` ) ; console . log ( ` ${ ( totalPrice * 0.20 ) . toFixed ( 2 ) } ` ) ; console . log ( ` ` ) ; console . log ( ` ${ finalPrice . toFixed ( 2 ) } ` ) ; } else { console . log ( 'Invalid order!' ) ; } }
Note: All prices should be displayed to the second digit after the decimal point!
Note : All prices should be displayed to the second digit after the decimal point!