-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pizza-pasta-salad #141
base: main
Are you sure you want to change the base?
pizza-pasta-salad #141
Conversation
- added an alert welcoming the user; - added a prompt to asked user to select one food option out of three; - added an alert to confirm the selected food option;
- added an image for the background
- added another while method for the age
- added a new javascript file to the folder
- changed the order option to drinks - added age - added order confirmation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job with this pizza bot Gitte 🍕
JavaScript
- Well structured control flow! Nice to see that you tried out the switch approach as well
- Nice that you're validating the input. The while loop will ensure proper answers from the user 👍
- Your naming of variables is generally good! Maybe they would be even clearer if firstOrder was renamed to mealType and secondOrder to dishType? Just a thought :)
- Don't forget to declare variables with const or let! And to put all global variables at the top of the file so that they're easier to find
Clean Code
- Make sure to indent your code properly, e.g. the else and else if statements should go on the previous line:
if (something) {
//
} else {
//
}
Keep up the good work! ⭐
code/index.html
Outdated
<script src="./script.js"></script> | ||
|
||
<!-- Second script with switch method --> | ||
<script src="./switch.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably just have one of these linked at once 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, both in script.js and switch.js you have demonstrated a good understanding in building interactive user interfaces for ordering systems. I think you have been very consistent with good readability and clean structure which makes it easy for me as a stranger, to understand the code (although additional comments would have been amazing)! 😊
Also great use of While loops!
else if (age < 13) { | ||
alert(`Thank you.You like to order a kid's ${secondOrder}. Click 'ok' to order`) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I found which maybe could have an improvement at this stage is that you could parse the age value and validate against potential edge cases (e.g., negative or unrealistic ages).
let age = parseInt(prompt(How old are you, ${name}?
));
while (isNaN(age) || age < 0 || age > 120) {
alert(Please enter a valid age.
);
age = parseInt(prompt(Enter your age:
));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Kelly! That's a good tipp!
https://pizza-pasta-salad.netlify.app/