Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Project Name

Replace this readme with your own information about your project. Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
For this project #4 we focused on basic JavaScript concepts like variables, conditionals, and native methods, Using alert() and prompt() to collect information from our customers

## The problem

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?
This time I was very focus in all the information we got from Disco, and I was focusing in 1 step at the time. I started by trying to understand the logic of each element, such as =, ==, ===, let, const, etc.

I would say that 90% of the time I was reading and collecting information from W3school and stack overflow, I tried to use chatgpt but sometimes it was giving me a very different way of building the project, I believe with more advance variables and conditionals.

If I had more time I would like to make it with the options that chatgpt suggested to see if it work better.

## View it live

Have you deployed your project somewhere? Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about


My site #4

https://precious-zabaione-04568c.netlify.app

98 changes: 95 additions & 3 deletions code/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,110 @@

// Step 1 - Welcome and introduction
// Your code goes here
alert(
`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`
)

alert("Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.")
let customerName = prompt("Please enter your name", "Your name")
alert("Hi " + customerName + "! What are you craving today? \nPlease press \"ok\” to continue.")
const errMsg = "Incorrect number, please enter 1, 2 or 3."

// Step 2 - Food choice
// Your code goes here

let foodChoice = ""
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)
}
}
Comment on lines +15 to +26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop was really cool! Nice that you get back to the same question again if you type the wrong answer!


alert("You have selected: " + foodChoice + ". Yummy!")

// Step 3 - Subtype choice
// Your code goes here

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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cool if you also included something in the message like, "What type of pizza would you like?" Please enter a number.....🤩

if (choice == 1) {
foodType = "Napolitana"
} else if (choice == 2) {
foodType = "Margherita"
} else if (choice == 3) {
foodType = "Sicilian"
} else {
alert(errMsg)
}
} else if (foodChoice == "Pasta") {
choice = prompt("Please enter a number: \n 1 - Fungui \n 2 - Ragú \n 3 - Carbonara", "Please type you number of choice here")
if (choice == 1) {
foodType = "Fungui"
} else if (choice == 2) {
foodType = "Ragú"
} else if (choice == 3) {
foodType = "Carbonara"
} else {
alert(errMsg)
}
} else if (foodChoice == "Salad") {
choice= prompt("Please enter a number: \n 1 - Caesar \n 2 - Greek \n 3 - Caprese", "Please type you number of choice here")
if (choice == 1) {
foodType = "Caesar"
} else if (choice == 2) {
foodType = "Greek"
} else if (choice == 3) {
foodType = "Caprese"
} else {
alert(errMsg)
}
}
}

alert("You have selected: " + foodType + ", great choice!")

// Step 4 - Age
// Your code goes here

let age
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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha what if I'm really old 👀

}
}
let price, size
if (age > 15) {
size = "an adult size "
price = 150
} else {
size = "a kid size "
price = 75
}

let confirm = ""
while (confirm == "") {
choice = prompt("You have chosen " + size + foodType + " " + foodChoice + ". This will cost you " + price + " kr. \nIs this correct? Please enter 1 - for Yes or 2 - for No")
if (choice == 1) {
confirm = 1
} else if (choice == 2) {
confirm = 2
} else {
alert("Please enter 1 or 2")
}
}

// Step 5 - Order confirmation
// Your code goes here

if (confirm == 1) {
alert("Thank you for your order! Your delicious meal will be prepared. See you soon " + String.fromCodePoint(0x1F920))
} else if (confirm == 2) {
alert("No problem, come back and order anytime you want!");
}