I have created a basic program that asks a customer…
How many tacos the customer wants to order
I want the for loop that is inside the function place_order to consol.log the pharase…
Your x amount of tacos are being prepared.
However, if the customer ordered 3 tacos; I want the message to be consol.loged 3 times.
If the customer typed 8 tacos – I want the message to be consol.loged 8 times.
How many tacos would you like to order
Customer inputs: 3
Output: your 3 tacos are being prepared
your 3 tacos are being prepared
your 3 tacos are being prepared
confirm = window.confirm("Hey there! Would you like to order some tacos?");
prompt = window.prompt("How many tacos would you like to order? (Maximum amount is 99 tacos")
console.log(confirm)
console.log(prompt)
function place_order(){
console.log("Your order will contain: " + prompt + " tacos!!!"); //This line confirms your order.
console.log("Your total is: " + prompt*5 + " USD."); //This line gives you the total $ spent.
for (let i = prompt; i <= prompt; i++){
console.log("Your " + prompt + " tacos are being prepared 🌮");
}
}
place_order()
2
Answers
You should start the index from 1, as you are starting it from the prompt input, that is why it is not working
Instead of
i <= prompt
, you should usei <= parseInt(prompt)
to convert the input to a number.Iuf the customer inputs 3, it will print: