From 4c1dda7460bf3907cab9abd067c94ba6d45a92ad Mon Sep 17 00:00:00 2001 From: ErikaOlsson Date: Tue, 3 Sep 2024 20:35:40 +0200 Subject: [PATCH 1/4] Update: Started project and down to instruction nr 3 --- code/script.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/code/script.js b/code/script.js index 34ca0f34..08c38e22 100644 --- a/code/script.js +++ b/code/script.js @@ -2,16 +2,93 @@ // 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 +if (typeOfFood === "1") { + let choosePizza = prompt("What type of pizza do you want?\n1. Margaritha\n2. Hawaii\n3. Vesuvio"); + if (choosePizza === "1") { + alert( + `You have chosen Margaritha!` + ) + } else if (choosePizza === "2") { + alert( + `You have chosen Hawaii!` + ) + } else if (choosePizza === "3") { + alert( + `You have chosen Vesuvio!` + ) + } +} else if (typeOfFood === "2") { + let choosePasta = prompt("What type of pasta do you want?\n1. Bolognese\n2. Puttanesca\n3. Carbonara"); + if (choosePasta === "1") { + alert( + `You have chosen Bolognese!` + ) + } else if (choosePasta === "2") { + alert( + `You have chosen Puttanesca!` + ) + } else if (choosePasta === "3") { + alert( + `You have chosen Carbonara!` + ) + } +} else if (typeOfFood === "3") { + let chooseSallad = prompt("What type of sallad do you want?\n1. Greek\n2. Shrimp\n3. Falafel"); + if (chooseSallad === "1") { + alert( + `You have chosen Greek!` + ) + } else if (chooseSallad === "2") { + alert( + `You have chosen Shrimp!` + ) + } else if (chooseSallad === "3") { + alert( + `You have chosen Falafel!` + ) + } +} + + + + + + // Step 4 - Age // Your code goes here From 499353d69b1c17776424604ad947cb2802e8ef52 Mon Sep 17 00:00:00 2001 From: ErikaOlsson Date: Wed, 4 Sep 2024 12:23:21 +0200 Subject: [PATCH 2/4] Update: chooseFoodSub --- code/script.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code/script.js b/code/script.js index 08c38e22..634e2947 100644 --- a/code/script.js +++ b/code/script.js @@ -36,12 +36,14 @@ if (typeOfFood === "1") { // 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 Margaritha!` + `You have chosen ${chooseFoodSub}!` ) } else if (choosePizza === "2") { alert( @@ -68,16 +70,16 @@ if (typeOfFood === "1") { ) } } else if (typeOfFood === "3") { - let chooseSallad = prompt("What type of sallad do you want?\n1. Greek\n2. Shrimp\n3. Falafel"); - if (chooseSallad === "1") { + let chooseSallad = parseInt(prompt("What type of sallad do you want?\n1. Greek\n2. Shrimp\n3. Falafel")) + if (chooseSallad === 1) { alert( `You have chosen Greek!` ) - } else if (chooseSallad === "2") { + } else if (chooseSallad === 2) { alert( `You have chosen Shrimp!` ) - } else if (chooseSallad === "3") { + } else if (chooseSallad === 3) { alert( `You have chosen Falafel!` ) @@ -85,10 +87,6 @@ if (typeOfFood === "1") { } - - - - // Step 4 - Age // Your code goes here From 5211f5f8b6d5690fe640f6264e2cfe71f3d9650d Mon Sep 17 00:00:00 2001 From: ErikaOlsson Date: Wed, 4 Sep 2024 15:14:29 +0200 Subject: [PATCH 3/4] Update: js pizzeria now working. --- code/script.js | 51 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/code/script.js b/code/script.js index 634e2947..3585ceeb 100644 --- a/code/script.js +++ b/code/script.js @@ -41,47 +41,55 @@ 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 + chooseFoodSub = "Margaritha" alert( `You have chosen ${chooseFoodSub}!` ) } else if (choosePizza === "2") { + chooseFoodSub = "Hawaii" alert( - `You have chosen Hawaii!` + `You have chosen ${chooseFoodSub}!` ) } else if (choosePizza === "3") { + chooseFoodSub = "Vesuvio" alert( - `You have chosen Vesuvio!` + `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 Bolognese!` + `You have chosen ${chooseFoodSub}!` ) } else if (choosePasta === "2") { + chooseFoodSub = "Puttanesca" alert( - `You have chosen Puttanesca!` + `You have chosen ${chooseFoodSub}!` ) } else if (choosePasta === "3") { + chooseFoodSub = "Carbonara" alert( - `You have chosen Carbonara!` + `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 Greek!` + `You have chosen ${chooseFoodSub}!` ) } else if (chooseSallad === 2) { + chooseFoodSub = "Shrimp Salad" alert( - `You have chosen Shrimp!` + `You have chosen ${chooseFoodSub}!` ) } else if (chooseSallad === 3) { + chooseFoodSub = "Falafel Salad" alert( - `You have chosen Falafel!` + `You have chosen ${chooseFoodSub}!` ) } } @@ -89,6 +97,31 @@ if (typeOfFood === "1") { // 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")) +} + // 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!` + ) +} \ No newline at end of file From 5f5b0112d91e4d4212f752c3cea08070bbe317d5 Mon Sep 17 00:00:00 2001 From: ErikaOlsson Date: Wed, 4 Sep 2024 21:20:39 +0200 Subject: [PATCH 4/4] Update: Live link and README file --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 33c7e601..01a7c8e8 100644 --- a/README.md +++ b/README.md @@ -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/