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

Elina Eriksson Hult - Project Pizza #144

Open
wants to merge 5 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
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# 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.
The assignment for this week was to create a Javascript pizzeria based on user inputs using methods like prompt and alert.

## The problem
During this week I approached many problems and it was hard to keep my head straight at times. I ended up trying stuff out and then deleting the code a few times to start over. I also got some help from a friend who's a programmer and he introduced me to functions in javascript. Afterwards I somehow ended up even more confused so I started over again and skipped using functions. Instead I used google, chatgpt and stack overflow to help me move forward. I also used the javascript pizzeria example on disco and took a lot of inspiration from that. Before I started coding I went to the example and tried to identify the different steps in the requirments and match them with the stages in the pizzeria example.

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?
If I had more time I would add while loops to my code to make sure the user has to choose an option before they leave for the next step or the page. In my code now the user has to refresh the page and start over if they would like to change something or picked the wrong option etc.

## 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://elinasjavascriptpizzeria.netlify.app/
105 changes: 95 additions & 10 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,104 @@
// Start here

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

let userName = prompt("Please enter your name:");

alert(`Hi, ${userName}!`)

// Step 2 - Food choice
// Your code goes here
let foodChoice = prompt("What type of food would you like to order?\nEnter a number:\n1 - Pizza\n2 - Pasta\n3 - Salad");

// User food coice
let foodName = "";
if (foodChoice === "1") {
foodName = "Pizza";
alert("You have selected Pizza!");
} else if (foodChoice === "2") {
foodName = "Pasta";
alert("You've selected Pasta");
} else if (foodChoice === "3") {
foodName = "Salad";
alert("You've selected Salad");
} else {
alert("Invalid choice, please enter a number between 1 and 3.");
}

//Step 3 Subtype choice
let subTypeChoice = "";
let subTypeName = "";

if (foodChoice === "1") {
// subtypes for pizza
subTypeChoice = prompt("Which type of Pizza would you like?\n1 - Margherita\n2 - Pepperoni\n3 - Vesuvio");
if (subTypeChoice === "1") {
subTypeName = "Margherita";
alert("You've selected Margherita!");
} else if (subTypeChoice === "2") {
subTypeName = "Pepperoni";
alert("You've selected Pepperoni!");
} else if (subTypeChoice === "3") {
subTypeName = "Vesuvio";
alert("You've selected Vesuvio!");
} else {
alert("Invalid choice, please enter a number between 1 and 3.");
}
} else if (foodChoice === "2") {
// subtypes for pasta
subTypeChoice = prompt("Which type of Pasta would you like?\n1 - Spaghetti Carbonara!\n2 - Lasagna!\n3 - Cheesy Tortellini!");
if (subTypeChoice === "1") {
subTypeName = "Spaghetti Carbonara";
alert("You've selected Spaghetti Carbonara!");
} else if (subTypeChoice === "2") {
subTypeName = "Lasagna";
alert("You've selected Lasagna!");
} else if (subTypeChoice === "3") {
subTypeName = "Cheesy Tortellini";
alert("You've selected Cheesy Tortellini!");
} else {
alert("Invalid choice, please enter a number between 1 and 3.");
}
} else if (foodChoice === "3") {
//subtypes for salad
subTypeChoice = prompt("Which type of salad would you like?\n1 - Ceasar Salad!\n2 - Greek Salad!\n3 - Garden Salad!");
if (subTypeChoice === "1") {
subTypeName = "Ceasar Salad";
alert("You've selected Ceasar Salad!");
} else if (subTypeChoice === "2") {
subTypeName = "Greek Salad";
alert("You've selected Greek Salad!");
} else if (subTypeChoice === "3") {
subTypeName = "Garden Salad";
alert("You've selected Garden Salad!");
} else {
alert("Invalid choice, please enter a number between 1 and 3.");
}
}

// Step 4 - Identify user's age
let userAge = prompt("Please enter your age:");

//variable to store the size and price based on age
let size = "";
let price = "";

// Step 3 - Subtype choice
// Your code goes here
// check if user is a child or an adult
if (userAge >= 18) {
size = "adult";
price = 15;
} else if (userAge > 0 && userAge < 18) {
size = "child";
price = 10;
} else {
alert("Invalid input, please enter a valid age");
}

// Step 4 - Age
// Your code goes here
let confirmation = prompt(`One ${size} sized ${subTypeName} will be prepared for you. That'll be €${price}. Are you sure you want to order this?\nEnter a number to confirm:\n1 - Yes\n2 - No`);

// Step 5 - Order confirmation
// Your code goes here
if (confirmation === "1") {
alert("Your order has been confirmed. Enjoy your meal!");
} else {
alert("Your order has been cancelled. Feel free to order our delicious food in the future!");
}
2 changes: 1 addition & 1 deletion code/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ body {

p {
font-size: 1.5em;
}
}
6 changes: 1 addition & 5 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
## Netlify link
Add your Netlify link here like this (update with the correct one):

https://my-netlify-link.netlify.app

PS. Don't forget to add it in your readme as well.
https://elinasjavascriptpizzeria.netlify.app/