Conversation
…ile loop. Added step 3.
HIPPIEKICK
left a comment
There was a problem hiding this comment.
Great work on tackling this project! 🎉
JavaScript
- Nice usage of the while loop and good control flow 👍
- You defined a helpful error message errMsg for incorrect input, which is great for user experience
- While using + to concatenate strings works, it's generally cleaner to use template literals (backticks) in modern JavaScript. It will make your code easier to read:
alert(`Hi ${customerName}! What are you craving today?`)
- Currently, the while loop relies on an empty string check to keep prompting the user. It might be cleaner and safer to check if the input is one of the valid options directly.
Overall, really good job with this project - these are just some things to consider going forward ⭐
| while (isNaN(age) == true || age < 1 || 100 < age) { | ||
| age = prompt("How old are you?", "Please type your age here") | ||
| if (isNaN(age) == true || age < 1 || 100 < age) { | ||
| alert("Please enter a valid age.") |
There was a problem hiding this comment.
Haha what if I'm really old 👀
EmelieNyberg
left a comment
There was a problem hiding this comment.
I tried your webpage and it worked really good! I even tried to fail som of the questions, but that was inpossible since you had made really cool loops for that😍
Great job with the project!
| let foodType = "" | ||
| while (foodType == "") { | ||
| if (foodChoice == "Pizza") { | ||
| choice = prompt("Please enter a number: \n 1 - Napolitana \n 2 - Margherita \n 3 - Sicilian", "Please type you number of choice here") |
There was a problem hiding this comment.
It would be cool if you also included something in the message like, "What type of pizza would you like?" Please enter a number.....🤩
| while (foodChoice == "") { | ||
| let choice = prompt("Please enter a number: \n 1 - Pizza \n 2 - Pasta \n 3 - Salad", "Please type you number of choice here") | ||
| if (choice == 1) { | ||
| foodChoice = "Pizza" | ||
| } else if (choice == 2) { | ||
| foodChoice = "Pasta" | ||
| } else if (choice == 3) { | ||
| foodChoice = "Salad" | ||
| } else { | ||
| alert(errMsg) | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop was really cool! Nice that you get back to the same question again if you type the wrong answer!
Netlify link
https://precious-zabaione-04568c.netlify.app/