Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function computerStore(input) {
- let totalPrice = 0, price;
- let command = input.shift();
- while (command != "special" && command != "regular") {
- price = Number(command);
- if (price > 0) {
- totalPrice += price;
- } else {
- console.log("Invalid price!")
- }
- command = input.shift();
- }
- if (totalPrice == 0) {
- console.log("Invalid order!");
- } else {
- console.log("Congratulations you've just bought a new computer!");
- console.log(`Price without taxes: ${totalPrice.toFixed(2)}$`);
- console.log(`Taxes: ${(totalPrice / 5).toFixed(2)}$`);
- console.log("-".repeat(11));
- console.log(`Total price: ${(totalPrice * 1.2 * (command === "special" ? 0.9 : 1)).toFixed(2)}$`);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement