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

JavaScript pizzeria :) #155

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
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.
Built a JavaScript Pizzeria
Mastering vital yet basic JavaScript concepts like variables, conditionals, and native methods.

## 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?
I used JavaScript concepts like variables, conditionals, and native methods.

## 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
https://66de0156d116e596d11ff09e--coruscating-basbousa-190b83.netlify.app/
109 changes: 105 additions & 4 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,120 @@
// Start here

// Step 1 - Welcome and introduction
// Your code goes here
alert(
`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`
)
// prompt to ask for the name and store the answer in a variable
const guestName = prompt('Please enter your name')
alert('Hi ' + guestName + '!')

// Step 2 - Food choice
// Your code goes here
// allow the user to select the type of food they want to order

const foodChoice = prompt('What type of food would you like to order?\Please enter a number:\ 1 - Pizza 2 - Pasta 3 - Salad');

if (foodChoice === '1') {
alert('You have chosen Pizza!')
} else if (foodChoice === '2') {
alert('You have chosen Pasta!')
}
else if (foodChoice === '3') {
alert('You have chosen Salad!')
}
else {
alert('Invalid choice. Please select a number between 1 and 3.')
}

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

// Pizza subtype
if (foodChoice === '1') {
const pizzaType = prompt('Select a Pizza type! \ Enter a number:\ 1 - Margherita 2 - Pepperoni 3 - Hawaiian')

if (pizzaType === '1') {
alert('You have chosen Margherita!')
selectedFoodType = 'Margherita'
} else if (pizzaType === '2') {
alert('You have chosen Pepperoni!')
selectedFoodType = Pepperoni
Copy link
Contributor

Choose a reason for hiding this comment

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

Pepperoni is not defined - should be quotation marks around it

Copy link
Author

Choose a reason for hiding this comment

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

Hi, @JennieDalgren made the requested changes to the JS file.

}
else if (pizzaType === '3') {
alert('You have chosen Hawaiian!')
selectedFoodType = 'Hawaiian'
}
else {
alert('Invalid choice. Please select a number between 1 and 3.')
}
}


// Pasta subtype

if (foodChoice === '2') {
const pastaType = prompt('Select a Pasta type! Enter a number: 1 - Spaghetti Carbonara: 2 - Pasta Bolognese 3 - Pasta Alfredo')

if (pastaType === '1') {
alert('You have chosen Spaghetti Carbonara!')
selectedFoodType = 'Spaghetti Carbonara'
} else if (pastaType === '2') {
alert('You have chosen Pasta Bolognese!')
selectedFoodType = 'Pasta Bolognese'
}
else if (pastaType === '3') {
alert('You have chosen Pasta Alfredo!')
selectedFoodType = 'Pasta Alfredo'
}
else {
alert('Invalid choice. Please select a number between 1 and 3.')
}
}

//Salad subtype

if (foodChoice === '3') {
const saladType = prompt('Select a Salad type! Enter a number: 1 - Caesar Salad 2 - Garden Salad 3 - Greek Salad')

if (saladType === '1') {
alert('You have chosen Caesar Salad!')
selectedFoodType = 'Ceaser Salad'
} else if (saladType === '2') {
alert('You have chosen Garden Salad!')
selectedFoodType = 'Garden Salad'
}
else if (saladType === '3') {
alert('You have chosen Greek Salad!')
selectedFoodType = 'Greek Salad'
}
else {
alert('Invalid choice. Please select a number between 1 and 3.')
}
}

// Step 4 - Age
// Your code goes here
const guestAge = prompt('Is this food for a child or an adult? Type your age:')
const age = Number(guestAge);

let finalPrice;
if (guestAge >= '13') {
// Adult
finalPrice = 15;
alert(`One ${selectedFoodType} will be prepared for you. That'll be €15.`);
}
else {
//Child
finalPrice = 10;
alert(`One child sized ${selectedFoodType} will be prepared for you. That'll be €10.`);
}

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

const confirmation = prompt(`Would you like to confirm your order? Type 'yes' or 'no'.`)

if (confirmation === 'yes') {
alert('Thank you! Your meal will be prepared shortly. The total cost is ' + finalPrice + '€')
}
else {
alert('We hope to see you again soon!');
}