Skip to content
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

project-3-pizza #138

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# 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.
This is an javascript pizzeria "machine" built so you can order pizza, pasta or salad online.

## 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?
It is built mainly with methods like alert() and prompt() and with Conditional statements to tie the answers from the prompts() (that are stored in variables) together.
This was a tought nut to crack and it took a few rounds of thinking (and some help from the team) to get it working. The toughest though I think was how to actually think of the problem before starting to code. I started the coding first and noticed that I had to redo it all almost on every step. Which made me realise the importance of writing down the solution in text first.

## 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
View site: https://js-pizzeria-place.netlify.app/
108 changes: 108 additions & 0 deletions code/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,126 @@

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

// 1:2
let name = prompt("What is your name?");

// 1:3
alert(
`Hello, ${name}!`
)

// Step 2 - Food choice
// Your code goes here
let typeOfFood = prompt("We offer the following food:\n1. Pizza\n2. Pasta\n3. Sallad\n\nWhat type of food do you want to order? Type the number of the food.");

if (typeOfFood === "1") {
alert(
`You have chosen pizza!`
)
} else if (typeOfFood === "2") {
alert(
`You have chosen pasta!`
)
} else if (typeOfFood === "3") {
alert(
`You have chosen sallad!`
)
}


// Step 3 - Subtype choice
// Your code goes here
let chooseFoodSub = ""

if (typeOfFood === "1") {
let choosePizza = prompt("What type of pizza do you want?\n1. Margaritha\n2. Hawaii\n3. Vesuvio");
if (choosePizza === "1") {
chooseFoodSub = "Margaritha"
alert(
`You have chosen ${chooseFoodSub}!`
)
} else if (choosePizza === "2") {
chooseFoodSub = "Hawaii"
alert(
`You have chosen ${chooseFoodSub}!`
)
} else if (choosePizza === "3") {
chooseFoodSub = "Vesuvio"
alert(
`You have chosen ${chooseFoodSub}!`
)
}
} else if (typeOfFood === "2") {
let choosePasta = prompt("What type of pasta do you want?\n1. Bolognese\n2. Puttanesca\n3. Carbonara");
if (choosePasta === "1") {
chooseFoodSub = "Bolognese"
alert(
`You have chosen ${chooseFoodSub}!`
)
} else if (choosePasta === "2") {
chooseFoodSub = "Puttanesca"
alert(
`You have chosen ${chooseFoodSub}!`
)
} else if (choosePasta === "3") {
chooseFoodSub = "Carbonara"
alert(
`You have chosen ${chooseFoodSub}!`
)
}
} else if (typeOfFood === "3") {
let chooseSallad = parseInt(prompt("What type of sallad do you want?\n1. Greek\n2. Shrimp\n3. Falafel"))
if (chooseSallad === 1) {
chooseFoodSub = "Greek Salad"
alert(
`You have chosen ${chooseFoodSub}!`
)
} else if (chooseSallad === 2) {
chooseFoodSub = "Shrimp Salad"
alert(
`You have chosen ${chooseFoodSub}!`
)
} else if (chooseSallad === 3) {
chooseFoodSub = "Falafel Salad"
alert(
`You have chosen ${chooseFoodSub}!`
)
}
}


// Step 4 - Age
// Your code goes here
let yourAge = parseInt(prompt("Do you want to order a kids or an adult meal? Enter you age below:"))
let confirmOrder = 0

if (yourAge <= 12) {
alert(
`You want to order one kids sized portion of our ${chooseFoodSub}!`
)
confirmOrder = parseInt(prompt("Do you want to confirm your order?\n1. Yes\n2. No"))
} else if (yourAge >= 13) {
alert(
`You want to order one adult sized portion of our ${chooseFoodSub}!`
)
confirmOrder = parseInt(prompt("Do you want to confirm your order?\n1. Yes\n2. No"))
}
Comment on lines +103 to +113
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if you move the confirmOrder to come after the if-else? 👀



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

if (confirmOrder === 1) {
alert(
`Thank you for your order at JavaScript Pizzeria. It will be ready and on its way in 15-20 minutes!`
)
} else if (confirmOrder === 2) {
alert(
`You have declined your order. But JavaScript Pizzera will be open for you if you change your mind. Hope to see you soon!`
)
}