From cff449ad72f1edf95c01a6fffe58120da7e0e394 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Tue, 3 Sep 2024 08:23:15 +0200 Subject: [PATCH 01/27] Testing to push project to GitHub --- code/index.html | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/code/index.html b/code/index.html index f7844d6b..76871ecf 100644 --- a/code/index.html +++ b/code/index.html @@ -1,18 +1,21 @@ + - - - - Javascript Pizzeria - - - - -

Javascript Pizzeria

-

Logic is executed automatically

- - - + + + + + Javascript Pizzeria + + + + + +

Javascript Pizzeria

+

Logic is executed automatically

+ + + + \ No newline at end of file From c877c285b7c9d4fcef28fa50b68c112b5bde1176 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Tue, 3 Sep 2024 14:41:46 +0200 Subject: [PATCH 02/27] Started the Javascript Pizzeria project --- code/script.js | 14 ++++++++++++++ code/style.css | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/code/script.js b/code/script.js index 34ca0f34..284a0712 100644 --- a/code/script.js +++ b/code/script.js @@ -6,8 +6,22 @@ alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) +const name = prompt( + `Hi hungry fellow! What's your name?` +) + +alert( + `Hello, ${name}! Hit the button below whenever you are ready to order!` +) + // Step 2 - Food choice // Your code goes here +const mealchoice = prompt( + 'What would you like to order?' 1. Pizza, 2. Pasta, 3. Salad.Please enter the number of your choice: +) +alert( + `Thanks, ${name}! You wish to order ${mealchoice}!` +) // Step 3 - Subtype choice // Your code goes here diff --git a/code/style.css b/code/style.css index d384d122..404c659d 100644 --- a/code/style.css +++ b/code/style.css @@ -17,4 +17,4 @@ body { p { font-size: 1.5em; -} +} \ No newline at end of file From 5b0a9ccd9fe26cb4202cea1dc0c71148a22d1cb2 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Tue, 3 Sep 2024 15:45:21 +0200 Subject: [PATCH 03/27] Started adding mealchoice prompts --- code/script.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/script.js b/code/script.js index 284a0712..d6cb75f5 100644 --- a/code/script.js +++ b/code/script.js @@ -17,10 +17,14 @@ alert( // Step 2 - Food choice // Your code goes here const mealchoice = prompt( - 'What would you like to order?' 1. Pizza, 2. Pasta, 3. Salad.Please enter the number of your choice: -) -alert( - `Thanks, ${name}! You wish to order ${mealchoice}!` + 'What would you like to order? 1. Pizza, 2. Pasta, 3. Salad. Please enter the number of your choice´ + + if (mealchoice === 1) + alert(`Thanks, ${name}! You wish to order Pizza!` + else if (mealchoice === 2)) +alert(`Thanks, ${name}! You wish to order Pasta!` + else if (mealchoice === 3)) +alert(`Thanks, ${name}! You wish to order Salad!`) ) // Step 3 - Subtype choice From ddb5a111f3aa1a8f5c015d6fff0d0329e8346357 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Tue, 3 Sep 2024 16:30:07 +0200 Subject: [PATCH 04/27] Finished mealchoices --- code/script.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/code/script.js b/code/script.js index d6cb75f5..3aea0558 100644 --- a/code/script.js +++ b/code/script.js @@ -16,16 +16,26 @@ alert( // Step 2 - Food choice // Your code goes here -const mealchoice = prompt( - 'What would you like to order? 1. Pizza, 2. Pasta, 3. Salad. Please enter the number of your choice´ - - if (mealchoice === 1) - alert(`Thanks, ${name}! You wish to order Pizza!` - else if (mealchoice === 2)) -alert(`Thanks, ${name}! You wish to order Pasta!` - else if (mealchoice === 3)) -alert(`Thanks, ${name}! You wish to order Salad!`) +let mealchoice = prompt( + `What would you like to order? 1. Pizza, 2. Pasta, 3. Salad. Please enter the number of your choice` ) +if (mealchoice === `1`) { + alert( + `Thanks, ${name}! You wish to order Pizza!` + ) +} else if (mealchoice === `2`) { + alert( + `Thanks, ${name}! You wish to order Pasta!` + ) +} else if (mealchoice === `3`) { + alert( + `Thanks, ${name}! You wish to order Salad!` + ) +} else { + alert( + `Sorry, ${name}! That's not a valid choice!` + ) +} // Step 3 - Subtype choice // Your code goes here From da7ee13f7b27b516166cedec15df1ef1ba996ddf Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 4 Sep 2024 10:44:39 +0200 Subject: [PATCH 05/27] Added the README file --- README.md | 20 +++++++++++++++----- code/script.js | 24 +++++++++++------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 33c7e601..18693dbb 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,21 @@ -# Project Name +# JavaScript Pizzeria -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 was to make a pizza order flow by using the JavaScript methods alert() and prompt(). -## The problem +## The Problem +The only real problem I had with this assignment was that the whole site stop to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. -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? +Other minor "problems" +I ”coded along” in CodePen to Amelies and Damiens instruction videos, and used the if else (https://codepen.io/joheri1/pen/RwzeYWa) that Damien showed on the tutorial. I wrote the below, and it didn’t work. + +if (mealchoice === 1) { + alert(”Thanks, ${name}! You wish to order Pizza!”) +}
 + +After a while I figured that it must be because I’m using digits and not text. Tested ”, ’ and ´ until I spotted that the backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert I used ` since it has ${name} in it. + +${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it really affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. ## View it live +Netlify link: https://johannas-js-pizzeria.netlify.app/ -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 diff --git a/code/script.js b/code/script.js index 3aea0558..9332c701 100644 --- a/code/script.js +++ b/code/script.js @@ -1,45 +1,43 @@ // Start here // Step 1 - Welcome and introduction -// Your code goes here alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) -const name = prompt( +const Cname = prompt( `Hi hungry fellow! What's your name?` ) alert( - `Hello, ${name}! Hit the button below whenever you are ready to order!` + `Hello, ${userName}! Hit the button below whenever you are ready to order!` ) // Step 2 - Food choice -// Your code goes here -let mealchoice = prompt( +const mealchoice = prompt( `What would you like to order? 1. Pizza, 2. Pasta, 3. Salad. Please enter the number of your choice` ) -if (mealchoice === `1`) { +if (mealchoice === "1") { alert( - `Thanks, ${name}! You wish to order Pizza!` + `Thanks, ${userName}! You wish to order Pizza!` ) -} else if (mealchoice === `2`) { +} else if (mealchoice === "2") { alert( - `Thanks, ${name}! You wish to order Pasta!` + `Thanks, ${userName}! You wish to order Pasta!` ) -} else if (mealchoice === `3`) { +} else if (mealchoice === "3") { alert( - `Thanks, ${name}! You wish to order Salad!` + `Thanks, ${userName}! You wish to order Salad!` ) } else { alert( - `Sorry, ${name}! That's not a valid choice!` + `Sorry, ${userName}! That's not a valid choice!` ) } - // Step 3 - Subtype choice // Your code goes here + // Step 4 - Age // Your code goes here From eda971026c6e9bc63b832f482d3d57c69747eb77 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 4 Sep 2024 11:08:45 +0200 Subject: [PATCH 06/27] Minor changes --- code/index.html | 1 - code/script.js | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/code/index.html b/code/index.html index 76871ecf..2030bff0 100644 --- a/code/index.html +++ b/code/index.html @@ -1,4 +1,3 @@ - diff --git a/code/script.js b/code/script.js index 9332c701..50a1a628 100644 --- a/code/script.js +++ b/code/script.js @@ -5,7 +5,7 @@ alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) -const Cname = prompt( +const userName = prompt( `Hi hungry fellow! What's your name?` ) @@ -15,7 +15,12 @@ alert( // Step 2 - Food choice const mealchoice = prompt( - `What would you like to order? 1. Pizza, 2. Pasta, 3. Salad. Please enter the number of your choice` + `What would you like to order? Please enter the number of your choice. + + 1. Pizza + 2. Pasta + 3. Salad + ` ) if (mealchoice === "1") { alert( @@ -35,6 +40,8 @@ if (mealchoice === "1") { ) } // Step 3 - Subtype choice +//Pizza + // Your code goes here From 451baaf3b46c98e521406cd33e24e34269ca4df2 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 4 Sep 2024 11:23:10 +0200 Subject: [PATCH 07/27] Added Pizza, Pasta and Salad choices --- code/script.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/code/script.js b/code/script.js index 50a1a628..7e0afc4d 100644 --- a/code/script.js +++ b/code/script.js @@ -41,6 +41,34 @@ if (mealchoice === "1") { } // Step 3 - Subtype choice //Pizza +if (mealchoice === "1") { + prompt( + `What type of Pizza you like to order? Please enter the number of your choice. + + 1. Capricciosa + 2. Hawaii + 3. Vesuvius + ` + ) +} else if (mealchoice === "2") { + prompt( + `What type of Pasta you like to order? Please enter the number of your choice. + + 1. Spagetti Bolognese + 2. Pasta Carbonara + 3. Fettuccine Alfredo + ` + ) +} else if (mealchoice === "3") { + prompt( + `What type of Salad you like to order? Please enter the number of your choice. + + 1. Pasta salad + 2. Noodle salad + 3. Something + ` + ) +} // Your code goes here From 6dc4328461c469cc8c98a5f233800f99892e14ec Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 4 Sep 2024 15:45:25 +0200 Subject: [PATCH 08/27] Step 4 - Age. Is the food for a child or an adult --- code/script.js | 112 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 32 deletions(-) diff --git a/code/script.js b/code/script.js index 7e0afc4d..3231ff03 100644 --- a/code/script.js +++ b/code/script.js @@ -22,59 +22,107 @@ const mealchoice = prompt( 3. Salad ` ) + if (mealchoice === "1") { alert( `Thanks, ${userName}! You wish to order Pizza!` ) -} else if (mealchoice === "2") { - alert( - `Thanks, ${userName}! You wish to order Pasta!` - ) -} else if (mealchoice === "3") { - alert( - `Thanks, ${userName}! You wish to order Salad!` - ) -} else { - alert( - `Sorry, ${userName}! That's not a valid choice!` - ) -} -// Step 3 - Subtype choice -//Pizza -if (mealchoice === "1") { - prompt( + + //Pizza + const pizzachoice = prompt( `What type of Pizza you like to order? Please enter the number of your choice. - 1. Capricciosa + 1. Capricciosa 2. Hawaii 3. Vesuvius ` ) + + if (pizzachoice === "1") { + orderedFood = "Capricciosa" + } else if (pizzachoice === "2") { + orderedFood = "Hawaii" + } else if (pizzachoice === "3") { + orderedFood = "Vesuvius" + } else { + alert("Sorry, we don't have that kind of pizza.") + } + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) + } + } else if (mealchoice === "2") { - prompt( - `What type of Pasta you like to order? Please enter the number of your choice. - - 1. Spagetti Bolognese - 2. Pasta Carbonara - 3. Fettuccine Alfredo - ` + alert( + `Thanks, ${userName}! You wish to order Pasta!` + ) + + //Pasta + const pastachoice = prompt( + `What type of Pasta you like to order ? Please enter the number of your choice. + + 1. Spagetti Bolognese + 2. Pasta Carbonara + 3. Fettuccine Alfredo + ` ) + + if (pastachoice === "1") { + orderedFood = "Spagetti Bolognese" + } else if (pastachoice === "2") { + orderedFood = "Pasta Carbonara" + } else if (pastachoice === "3") { + orderedFood = "Fettuccine Alfredo" + } else { + alert("Sorry, we don't have that kind of pasta.") + } + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) + } + } else if (mealchoice === "3") { - prompt( - `What type of Salad you like to order? Please enter the number of your choice. + alert( + `Thanks, ${userName}! You wish to order Salad!` + ) + + //Salad + const saladchoice = prompt( + `What type of Salad you like to order ? Please enter the number of your choice. 1. Pasta salad 2. Noodle salad - 3. Something - ` + 3. Ceaser salad + ` ) -} -// Your code goes here + if (saladchoice === "1") { + orderedFood = "Pasta salad" + } else if (saladchoice === "2") { + orderedFood = "Noodle salad" + } else if (saladchoice === "3") { + orderedFood = "Ceaser salad" + } else { + alert("Sorry, we don't have that kind of salad.") + } + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) + } +} else { + alert( + `Sorry, ${userName}! That's not a valid choice!` + ) +} // Step 4 - Age -// Your code goes here +const age = prompt ( + `Is this food for a child or an adult? Type your age:` +) +if (age >= 18) + alert("The food is for an adult") + else { + alert ("The food is for a child") + } // Step 5 - Order confirmation // Your code goes here + From fbd4fb6c2f8c001881e93a117816b9c9346d2e27 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 4 Sep 2024 16:02:27 +0200 Subject: [PATCH 09/27] Updated the README --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 18693dbb..95b444a7 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,30 @@ The assignment was to make a pizza order flow by using the JavaScript methods alert() and prompt(). ## The Problem -The only real problem I had with this assignment was that the whole site stop to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. +The biggest problem I had with this assignment was that the whole site stop to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. Other minor "problems" I ”coded along” in CodePen to Amelies and Damiens instruction videos, and used the if else (https://codepen.io/joheri1/pen/RwzeYWa) that Damien showed on the tutorial. I wrote the below, and it didn’t work. if (mealchoice === 1) { alert(”Thanks, ${name}! You wish to order Pizza!”) -}
 +} After a while I figured that it must be because I’m using digits and not text. Tested ”, ’ and ´ until I spotted that the backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert I used ` since it has ${name} in it. +Old variable? ${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it really affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. +Nesting +At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because everytime I saved the code, it moved to the left hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. + +## If I had more time +I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. + +I would also like to create a loop, so you don't have to start all over when you select a invalid option. + +Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. + ## View it live Netlify link: https://johannas-js-pizzeria.netlify.app/ From 4b1a1a3d8fbd1fe6ef8e5c01399c2ae45e7f9dee Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 4 Sep 2024 16:05:56 +0200 Subject: [PATCH 10/27] Minor updates --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 95b444a7..412458e4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ if (mealchoice === 1) { alert(”Thanks, ${name}! You wish to order Pizza!”) } -After a while I figured that it must be because I’m using digits and not text. Tested ”, ’ and ´ until I spotted that the backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert I used ` since it has ${name} in it. +After a while I figured that it must be because I’m using digits and not text. Tested ”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert I used ` since it has ${name} in it. Old variable? ${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it really affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. @@ -21,6 +21,8 @@ Nesting At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because everytime I saved the code, it moved to the left hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time +Focus on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself alot when writing the code. + I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. I would also like to create a loop, so you don't have to start all over when you select a invalid option. From 57dc0b934081e49ad1d8bbe1b89fd76a988a8695 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 08:14:54 +0200 Subject: [PATCH 11/27] Step 5. Confirmation --- code/script.js | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/code/script.js b/code/script.js index 3231ff03..9be05890 100644 --- a/code/script.js +++ b/code/script.js @@ -39,11 +39,11 @@ if (mealchoice === "1") { ) if (pizzachoice === "1") { - orderedFood = "Capricciosa" + orderedFood = "Capricciosa pizza" } else if (pizzachoice === "2") { - orderedFood = "Hawaii" + orderedFood = "Hawaii pizza" } else if (pizzachoice === "3") { - orderedFood = "Vesuvius" + orderedFood = "Vesuvius pizza" } else { alert("Sorry, we don't have that kind of pizza.") } @@ -104,7 +104,7 @@ if (mealchoice === "1") { alert("Sorry, we don't have that kind of salad.") } if (orderedFood) { - alert(`You've chosen ${orderedFood}`) + alert(`You've selected ${orderedFood}`) } } else { @@ -117,12 +117,30 @@ if (mealchoice === "1") { const age = prompt ( `Is this food for a child or an adult? Type your age:` ) -if (age >= 18) - alert("The food is for an adult") - else { - alert ("The food is for a child") - } +let portion = "" +if (parseInt(age) >= 18) { + portion = "regular portion" +} +else { + portion = "kid's meal" +} + +alert( + `You wish to order a ${portion}` +) // Step 5 - Order confirmation -// Your code goes here +const confirmation = confirm + +if (confirmation) { + alert(`Thank you for your order, ${userName}! + + Your ${orderedFood} (${portion}) will be prepared shortly. + + We hope you enjoy your meal!`) +}else { + alert(`No worries, ${userName}. + +Thank you for visiting our Javascript Pizzeria. We hope to serve you next time!`); +} From 9ab7a3839a2ae6d6bfcb2e0c7054ffdbf37d88cd Mon Sep 17 00:00:00 2001 From: Johanna Eriksson <43312637+joheri1@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:19:34 +0200 Subject: [PATCH 12/27] Update README.md --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 412458e4..3dee8c6f 100644 --- a/README.md +++ b/README.md @@ -3,31 +3,31 @@ The assignment was to make a pizza order flow by using the JavaScript methods alert() and prompt(). ## The Problem -The biggest problem I had with this assignment was that the whole site stop to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. +The biggest problem I had with this assignment was that the whole site stops to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. -Other minor "problems" -I ”coded along” in CodePen to Amelies and Damiens instruction videos, and used the if else (https://codepen.io/joheri1/pen/RwzeYWa) that Damien showed on the tutorial. I wrote the below, and it didn’t work. +### Other minor "problems" +1. I ”coded along” in CodePen to Amelies and Damiens instruction videos, and used the if else (https://codepen.io/joheri1/pen/RwzeYWa) that Damien showed on the tutorial. I wrote the below, and it didn’t work. if (mealchoice === 1) { alert(”Thanks, ${name}! You wish to order Pizza!”) } -After a while I figured that it must be because I’m using digits and not text. Tested ”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert I used ` since it has ${name} in it. +After a while, I figured it must be because I was using digits, not text. I tested”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert, I used ` since it has ${name} in it. -Old variable? -${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it really affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. +### Old variable? +${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. -Nesting -At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because everytime I saved the code, it moved to the left hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. +### Nesting +At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -Focus on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself alot when writing the code. +1. Focus on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. -I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. +2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. -I would also like to create a loop, so you don't have to start all over when you select a invalid option. +3. I would also like to create a loop, so you don't have to start all over when you select a invalid option. -Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. +4. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. ## View it live Netlify link: https://johannas-js-pizzeria.netlify.app/ From d1c18d46a823887b3f00e7938420c74064021cc1 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson <43312637+joheri1@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:20:38 +0200 Subject: [PATCH 13/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3dee8c6f..c1dbe270 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ ${name} turned into a strikethrough text. When I hovered over it, it said ”'na At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -1. Focus on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. +1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. 2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. From d89b6bb9b134643ba00a96fa4938e8240609454b Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 08:27:45 +0200 Subject: [PATCH 14/27] Updated the confirmation --- code/script.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/code/script.js b/code/script.js index 9be05890..8e5f85ee 100644 --- a/code/script.js +++ b/code/script.js @@ -130,10 +130,19 @@ alert( ) // Step 5 - Order confirmation -const confirmation = confirm +const confirmation = prompt( + `Thank you, ${userName}, for your order of a ${portion} of ${orderedFood}! + + Are you sure you want to order this? + + 1. Yes + 2. No +` +) -if (confirmation) { - alert(`Thank you for your order, ${userName}! +if (confirmation === "1") { + alert(` + Thank you for your order, ${userName}! Your ${orderedFood} (${portion}) will be prepared shortly. From da54fd501015c76b0e7aff74dfde956590c9cc1b Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 08:29:45 +0200 Subject: [PATCH 15/27] Updated comfirmation --- code/script.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/script.js b/code/script.js index 8e5f85ee..783fc5e0 100644 --- a/code/script.js +++ b/code/script.js @@ -151,5 +151,4 @@ if (confirmation === "1") { alert(`No worries, ${userName}. Thank you for visiting our Javascript Pizzeria. We hope to serve you next time!`); -} - +} \ No newline at end of file From 50a219bd05f5973cff5a593a4f6c28fb6dfa14b7 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 08:32:55 +0200 Subject: [PATCH 16/27] Final updates --- README.md | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 412458e4..28c40c22 100644 --- a/README.md +++ b/README.md @@ -3,32 +3,31 @@ The assignment was to make a pizza order flow by using the JavaScript methods alert() and prompt(). ## The Problem -The biggest problem I had with this assignment was that the whole site stop to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. +The biggest problem I had with this assignment was that the whole site stops to function when there’s something broken in the code. CSS and HTML are more ”forgiving”. -Other minor "problems" -I ”coded along” in CodePen to Amelies and Damiens instruction videos, and used the if else (https://codepen.io/joheri1/pen/RwzeYWa) that Damien showed on the tutorial. I wrote the below, and it didn’t work. +### Other minor "problems" +1. I ”coded along” in CodePen to Amelies and Damiens instruction videos, and used the if else (https://codepen.io/joheri1/pen/RwzeYWa) that Damien showed on the tutorial. I wrote the below, and it didn’t work. if (mealchoice === 1) { alert(”Thanks, ${name}! You wish to order Pizza!”) } -After a while I figured that it must be because I’m using digits and not text. Tested ”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert I used ` since it has ${name} in it. +After a while, I figured it must be because I was using digits, not text. I tested”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert, I used ` since it has ${name} in it. -Old variable? -${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it really affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. +### Old variable? +${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. -Nesting -At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because everytime I saved the code, it moved to the left hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. +### Nesting +At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -Focus on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself alot when writing the code. +1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. -I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. +2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. -I would also like to create a loop, so you don't have to start all over when you select a invalid option. +3. I would also like to create a loop, so you don't have to start all over when you select a invalid option. -Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. +4. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. ## View it live -Netlify link: https://johannas-js-pizzeria.netlify.app/ - +Netlify link: https://johannas-js-pizzeria.netlify.app/ \ No newline at end of file From 77ad98d48010dbfed4c7590f1c7b8fdd6b7d81ee Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 14:46:51 +0200 Subject: [PATCH 17/27] Added switch.js file and started with the stretch goals --- code/index.html | 2 +- code/script.js | 74 ++++++------------------ code/switch.js | 150 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 59 deletions(-) create mode 100644 code/switch.js diff --git a/code/index.html b/code/index.html index 2030bff0..a0123c31 100644 --- a/code/index.html +++ b/code/index.html @@ -14,7 +14,7 @@

Javascript Pizzeria

Logic is executed automatically

- + \ No newline at end of file diff --git a/code/script.js b/code/script.js index 783fc5e0..0d69a9e6 100644 --- a/code/script.js +++ b/code/script.js @@ -14,56 +14,31 @@ alert( ) // Step 2 - Food choice +const EnterChoice = "Please enter the number of your choice." + const mealchoice = prompt( - `What would you like to order? Please enter the number of your choice. - - 1. Pizza - 2. Pasta - 3. Salad - ` + `What would you like to order? Please enter the number of your choice.\n\n1. Pizza\n2. Pasta\n3. Salad` ) -if (mealchoice === "1") { - alert( - `Thanks, ${userName}! You wish to order Pizza!` - ) +let orderedFood = "" - //Pizza +//Pizza +if (mealchoice === "1") { const pizzachoice = prompt( - `What type of Pizza you like to order? Please enter the number of your choice. - - 1. Capricciosa - 2. Hawaii - 3. Vesuvius - ` + `What type of Pizza you like to order? ${EnterChoice}.\n\n1. Capricciosa\n2. Hawaii\n3. Vesuvius` ) - + // if (pizzachoice === "1") { orderedFood = "Capricciosa pizza" } else if (pizzachoice === "2") { orderedFood = "Hawaii pizza" } else if (pizzachoice === "3") { orderedFood = "Vesuvius pizza" - } else { - alert("Sorry, we don't have that kind of pizza.") - } - if (orderedFood) { - alert(`You've chosen ${orderedFood}`) } - -} else if (mealchoice === "2") { - alert( - `Thanks, ${userName}! You wish to order Pasta!` - ) - //Pasta +} else if (mealchoice === "2") { const pastachoice = prompt( - `What type of Pasta you like to order ? Please enter the number of your choice. - - 1. Spagetti Bolognese - 2. Pasta Carbonara - 3. Fettuccine Alfredo - ` + `What type of Pasta you like to order? ${EnterChoice}\n\n1. Spagetti Bolognese 2. Pasta Carbonara 3. Fettuccine Alfredo` ) if (pastachoice === "1") { @@ -72,26 +47,11 @@ if (mealchoice === "1") { orderedFood = "Pasta Carbonara" } else if (pastachoice === "3") { orderedFood = "Fettuccine Alfredo" - } else { - alert("Sorry, we don't have that kind of pasta.") } - if (orderedFood) { - alert(`You've chosen ${orderedFood}`) - } - -} else if (mealchoice === "3") { - alert( - `Thanks, ${userName}! You wish to order Salad!` - ) - //Salad +} else if (mealchoice === "3") { const saladchoice = prompt( - `What type of Salad you like to order ? Please enter the number of your choice. - - 1. Pasta salad - 2. Noodle salad - 3. Ceaser salad - ` + `What type of Salad you like to order? ${EnterChoice}\n\n1. Pasta salad \n2. Noodle salad \n3. Ceaser salad` ) if (saladchoice === "1") { @@ -100,17 +60,15 @@ if (mealchoice === "1") { orderedFood = "Noodle salad" } else if (saladchoice === "3") { orderedFood = "Ceaser salad" - } else { - alert("Sorry, we don't have that kind of salad.") - } - if (orderedFood) { - alert(`You've selected ${orderedFood}`) } - + //If user selects a valid food choice + if (orderedFood) + alert(`Thanks ${userName}! You've chosen ${orderedFood}`) } else { alert( `Sorry, ${userName}! That's not a valid choice!` ) + return; // Stop the script here } // Step 4 - Age diff --git a/code/switch.js b/code/switch.js new file mode 100644 index 00000000..80b5ed79 --- /dev/null +++ b/code/switch.js @@ -0,0 +1,150 @@ +// Start here + +// Step 1 - Welcome and introduction +alert( + `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` + ) + + const userName = prompt( + `Hi hungry fellow! What's your name?` + ) + + alert( + `Hello, ${userName}! Hit the button below whenever you are ready to order!` + ) + + // Step 2 - Food choice + const mealchoice = prompt( + `What would you like to order? Please enter the number of your choice. + + 1. Pizza + 2. Pasta + 3. Salad + ` + ) + //Pizza + if (mealchoice === "1") { + const pizzachoice = prompt( + `Thanks, ${userName}! You wish to order Pizza! + + What type of Pizza you like to order? Please enter the number of your choice. + + 1. Capricciosa + 2. Hawaii + 3. Vesuvius + ` + ) + if (pizzachoice === "1") { + orderedFood = "Capricciosa pizza" + } else if (pizzachoice === "2") { + orderedFood = "Hawaii pizza" + } else if (pizzachoice === "3") { + orderedFood = "Vesuvius pizza" + } else { + alert("Sorry, we don't have that kind of pizza.") + } + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) + } + + } else if (mealchoice === "2") { + alert( + `Thanks, ${userName}! You wish to order Pasta!` + ) + + //Pasta + const pastachoice = prompt( + `What type of Pasta you like to order ? Please enter the number of your choice. + + 1. Spagetti Bolognese + 2. Pasta Carbonara + 3. Fettuccine Alfredo + ` + ) + + if (pastachoice === "1") { + orderedFood = "Spagetti Bolognese" + } else if (pastachoice === "2") { + orderedFood = "Pasta Carbonara" + } else if (pastachoice === "3") { + orderedFood = "Fettuccine Alfredo" + } else { + alert("Sorry, we don't have that kind of pasta.") + } + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) + } + + } else if (mealchoice === "3") { + alert( + `Thanks, ${userName}! You wish to order Salad!` + ) + + //Salad + const saladchoice = prompt( + `What type of Salad you like to order ? Please enter the number of your choice. + + 1. Pasta salad + 2. Noodle salad + 3. Ceaser salad + ` + ) + + if (saladchoice === "1") { + orderedFood = "Pasta salad" + } else if (saladchoice === "2") { + orderedFood = "Noodle salad" + } else if (saladchoice === "3") { + orderedFood = "Ceaser salad" + } else { + alert("Sorry, we don't have that kind of salad.") + } + if (orderedFood) { + alert(`You've selected ${orderedFood}`) + } + + } else { + alert( + `Sorry, ${userName}! That's not a valid choice!` + ) + } + + // Step 4 - Age + const age = prompt ( + `Is this food for a child or an adult? Type your age:` + ) + let portion = "" + if (parseInt(age) >= 18) { + portion = "regular portion" + } + else { + portion = "kid's meal" + } + + alert( + `You wish to order a ${portion}` + ) + + // Step 5 - Order confirmation + const confirmation = prompt( + `Thank you, ${userName}, for your order of a ${portion} of ${orderedFood}! + + Are you sure you want to order this? + + 1. Yes + 2. No + ` + ) + + if (confirmation === "1") { + alert(` + Thank you for your order, ${userName}! + + Your ${orderedFood} (${portion}) will be prepared shortly. + + We hope you enjoy your meal!`) + }else { + alert(`No worries, ${userName}. + + Thank you for visiting our Javascript Pizzeria. We hope to serve you next time!`); + } \ No newline at end of file From b7ae828ce34222bb06a6b29eefbfd73bdc3eefb6 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 14:50:24 +0200 Subject: [PATCH 18/27] Updated README-file --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 28c40c22..064b2144 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ ${name} turned into a strikethrough text. When I hovered over it, it said ”'na At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. +1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. Update: I started to do this in the switch.js file. -2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. +2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. Update: I started to do this in the switch.js file. 3. I would also like to create a loop, so you don't have to start all over when you select a invalid option. From f30790aef2fd28d6aaf2083c939263334e24eb54 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 15:32:38 +0200 Subject: [PATCH 19/27] Accidently updated the wrong file, so I corrected that mistake --- code/script.js | 86 +++++++++++++++------- code/switch.js | 190 ++++++++++++++++++++----------------------------- 2 files changed, 141 insertions(+), 135 deletions(-) diff --git a/code/script.js b/code/script.js index 0d69a9e6..8a326a9d 100644 --- a/code/script.js +++ b/code/script.js @@ -14,31 +14,52 @@ alert( ) // Step 2 - Food choice -const EnterChoice = "Please enter the number of your choice." - const mealchoice = prompt( - `What would you like to order? Please enter the number of your choice.\n\n1. Pizza\n2. Pasta\n3. Salad` + `What would you like to order? Please enter the number of your choice. + + 1. Pizza + 2. Pasta + 3. Salad + ` ) - -let orderedFood = "" - -//Pizza + //Pizza if (mealchoice === "1") { const pizzachoice = prompt( - `What type of Pizza you like to order? ${EnterChoice}.\n\n1. Capricciosa\n2. Hawaii\n3. Vesuvius` - ) - // - if (pizzachoice === "1") { - orderedFood = "Capricciosa pizza" - } else if (pizzachoice === "2") { - orderedFood = "Hawaii pizza" - } else if (pizzachoice === "3") { - orderedFood = "Vesuvius pizza" + `Thanks, ${userName}! You wish to order Pizza! + + What type of Pizza you like to order? Please enter the number of your choice. + + 1. Capricciosa + 2. Hawaii + 3. Vesuvius + ` + ) + if (pizzachoice === "1") { + orderedFood = "Capricciosa pizza" + } else if (pizzachoice === "2") { + orderedFood = "Hawaii pizza" + } else if (pizzachoice === "3") { + orderedFood = "Vesuvius pizza" + } else { + alert("Sorry, we don't have that kind of pizza.") + } + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) } - //Pasta + } else if (mealchoice === "2") { + alert( + `Thanks, ${userName}! You wish to order Pasta!` + ) + + //Pasta const pastachoice = prompt( - `What type of Pasta you like to order? ${EnterChoice}\n\n1. Spagetti Bolognese 2. Pasta Carbonara 3. Fettuccine Alfredo` + `What type of Pasta you like to order ? Please enter the number of your choice. + + 1. Spagetti Bolognese + 2. Pasta Carbonara + 3. Fettuccine Alfredo + ` ) if (pastachoice === "1") { @@ -47,11 +68,26 @@ if (mealchoice === "1") { orderedFood = "Pasta Carbonara" } else if (pastachoice === "3") { orderedFood = "Fettuccine Alfredo" + } else { + alert("Sorry, we don't have that kind of pasta.") } - //Salad + if (orderedFood) { + alert(`You've chosen ${orderedFood}`) + } + } else if (mealchoice === "3") { + alert( + `Thanks, ${userName}! You wish to order Salad!` + ) + + //Salad const saladchoice = prompt( - `What type of Salad you like to order? ${EnterChoice}\n\n1. Pasta salad \n2. Noodle salad \n3. Ceaser salad` + `What type of Salad you like to order ? Please enter the number of your choice. + + 1. Pasta salad + 2. Noodle salad + 3. Ceaser salad + ` ) if (saladchoice === "1") { @@ -60,15 +96,17 @@ if (mealchoice === "1") { orderedFood = "Noodle salad" } else if (saladchoice === "3") { orderedFood = "Ceaser salad" + } else { + alert("Sorry, we don't have that kind of salad.") } - //If user selects a valid food choice - if (orderedFood) - alert(`Thanks ${userName}! You've chosen ${orderedFood}`) + if (orderedFood) { + alert(`You've selected ${orderedFood}`) + } + } else { alert( `Sorry, ${userName}! That's not a valid choice!` ) - return; // Stop the script here } // Step 4 - Age diff --git a/code/switch.js b/code/switch.js index 80b5ed79..c49a2521 100644 --- a/code/switch.js +++ b/code/switch.js @@ -1,150 +1,118 @@ -// Start here - // Step 1 - Welcome and introduction alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` - ) - - const userName = prompt( +) + +const userName = prompt( `Hi hungry fellow! What's your name?` - ) - - alert( +) + +alert( `Hello, ${userName}! Hit the button below whenever you are ready to order!` - ) - - // Step 2 - Food choice - const mealchoice = prompt( - `What would you like to order? Please enter the number of your choice. - - 1. Pizza - 2. Pasta - 3. Salad - ` - ) - //Pizza - if (mealchoice === "1") { +) + +// Step 2 - Food choice +const EnterChoice = "Please enter the number of your choice." + +const mealchoice = prompt( + `What would you like to order? Please enter the number of your choice.\n\n1. Pizza\n2. Pasta\n3. Salad` +) + +let orderedFood = "" + +// Pizza + +if (mealchoice === "1") { const pizzachoice = prompt( - `Thanks, ${userName}! You wish to order Pizza! - - What type of Pizza you like to order? Please enter the number of your choice. - - 1. Capricciosa - 2. Hawaii - 3. Vesuvius - ` - ) - if (pizzachoice === "1") { - orderedFood = "Capricciosa pizza" - } else if (pizzachoice === "2") { - orderedFood = "Hawaii pizza" - } else if (pizzachoice === "3") { - orderedFood = "Vesuvius pizza" - } else { - alert("Sorry, we don't have that kind of pizza.") - } - if (orderedFood) { - alert(`You've chosen ${orderedFood}`) - } - - } else if (mealchoice === "2") { - alert( - `Thanks, ${userName}! You wish to order Pasta!` + `What type of Pizza would you like to order? ${EnterChoice}.\n\n1. Capricciosa\n2. Hawaii\n3. Vesuvius` ) - - //Pasta + + if (pizzachoice === "1") { + orderedFood = "Capricciosa pizza" + } else if (pizzachoice === "2") { + orderedFood = "Hawaii pizza" + } else if (pizzachoice === "3") { + orderedFood = "Vesuvius pizza" + } else { + alert("Sorry, that's not a valid pizza choice.") + //return // Stop the script here if an invalid pizza choice is made + } + +// Pasta + +} else if (mealchoice === "2") { const pastachoice = prompt( - `What type of Pasta you like to order ? Please enter the number of your choice. - - 1. Spagetti Bolognese - 2. Pasta Carbonara - 3. Fettuccine Alfredo - ` + `What type of Pasta would you like to order? ${EnterChoice}\n\n1. Spaghetti Bolognese\n2. Pasta Carbonara\n3. Fettuccine Alfredo` ) if (pastachoice === "1") { - orderedFood = "Spagetti Bolognese" + orderedFood = "Spaghetti Bolognese" } else if (pastachoice === "2") { - orderedFood = "Pasta Carbonara" + orderedFood = "Pasta Carbonara" } else if (pastachoice === "3") { - orderedFood = "Fettuccine Alfredo" + orderedFood = "Fettuccine Alfredo" } else { - alert("Sorry, we don't have that kind of pasta.") - } - if (orderedFood) { - alert(`You've chosen ${orderedFood}`) + alert("Sorry, that's not a valid pasta choice.") + //return // Stop the script here if an invalid pasta choice is made } - - } else if (mealchoice === "3") { - alert( - `Thanks, ${userName}! You wish to order Salad!` - ) - - //Salad + +} else if (mealchoice === "3") { // Salad const saladchoice = prompt( - `What type of Salad you like to order ? Please enter the number of your choice. - - 1. Pasta salad - 2. Noodle salad - 3. Ceaser salad - ` + `What type of Salad would you like to order? ${EnterChoice}\n\n1. Pasta salad\n2. Noodle salad\n3. Caesar salad` ) if (saladchoice === "1") { - orderedFood = "Pasta salad" + orderedFood = "Pasta salad" } else if (saladchoice === "2") { - orderedFood = "Noodle salad" + orderedFood = "Noodle salad" } else if (saladchoice === "3") { - orderedFood = "Ceaser salad" + orderedFood = "Caesar salad" } else { - alert("Sorry, we don't have that kind of salad.") - } - if (orderedFood) { - alert(`You've selected ${orderedFood}`) + alert("Sorry, that's not a valid salad choice.") + //return // Stop the script here if an invalid salad choice is made } - - } else { + +} else { alert( `Sorry, ${userName}! That's not a valid choice!` ) - } - - // Step 4 - Age - const age = prompt ( + //return // Stop the script here if an invalid meal choice is made +} + +// Confirm the selected food choice +if (orderedFood) { + alert(`Thanks ${userName}! You've chosen ${orderedFood}`) +} + +// Step 4 - Age +const age = prompt ( `Is this food for a child or an adult? Type your age:` - ) - let portion = "" - if (parseInt(age) >= 18) { +) +let portion = "" +if (parseInt(age) >= 18) { portion = "regular portion" - } - else { +} else { portion = "kid's meal" - } - - alert( +} + +alert( `You wish to order a ${portion}` - ) - - // Step 5 - Order confirmation - const confirmation = prompt( - `Thank you, ${userName}, for your order of a ${portion} of ${orderedFood}! - - Are you sure you want to order this? - - 1. Yes - 2. No - ` - ) - - if (confirmation === "1") { +) + +// Step 5 - Order confirmation +const confirmation = prompt( + `Thank you, ${userName}, for your order of a ${portion} of ${orderedFood}!\n\nAre you sure you want to order this?\n\n1. Yes\n2. No` +) + +if (confirmation === "1") { alert(` Thank you for your order, ${userName}! Your ${orderedFood} (${portion}) will be prepared shortly. We hope you enjoy your meal!`) - }else { +} else { alert(`No worries, ${userName}. Thank you for visiting our Javascript Pizzeria. We hope to serve you next time!`); - } \ No newline at end of file +} From 83ce4d2b553e5d4818a1bdfd95f529dcbc4370c1 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 15:34:57 +0200 Subject: [PATCH 20/27] Added more to the README-file --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 064b2144..abb4b567 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,13 @@ ${name} turned into a strikethrough text. When I hovered over it, it said ”'na At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. Update: I started to do this in the switch.js file. +1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. +Update: I started to do this in the switch.js file. -2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. Update: I started to do this in the switch.js file. +2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. +Update: I started to do this in the switch.js file. -3. I would also like to create a loop, so you don't have to start all over when you select a invalid option. +4. I would also like to get the "return" to function in order to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. 4. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. From acf944e99dc4d68c9de59ba9ee4d0f6822b3abd4 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson <43312637+joheri1@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:38:22 +0200 Subject: [PATCH 21/27] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index abb4b567..0cf7a26a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ if (mealchoice === 1) { alert(”Thanks, ${name}! You wish to order Pizza!”) } -After a while, I figured it must be because I was using digits, not text. I tested”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert, I used ` since it has ${name} in it. +After a while, I figured it must be because I was using digits, not text. I tested”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using the backtick. So I used ”” for the meal choices (since it has to be only text) and for the alert, I used ` since it has ${name} in it. ### Old variable? ${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. @@ -27,9 +27,9 @@ Update: I started to do this in the switch.js file. 2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. Update: I started to do this in the switch.js file. -4. I would also like to get the "return" to function in order to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. +4. I would also like to get the "return" to function to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. 4. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. ## View it live -Netlify link: https://johannas-js-pizzeria.netlify.app/ \ No newline at end of file +Netlify link: https://johannas-js-pizzeria.netlify.app/ From a79f15aff3407b5f875070fd31e28363cd64d89c Mon Sep 17 00:00:00 2001 From: Johanna Eriksson <43312637+joheri1@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:42:28 +0200 Subject: [PATCH 22/27] Update README.md --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0cf7a26a..074f3402 100644 --- a/README.md +++ b/README.md @@ -21,15 +21,16 @@ ${name} turned into a strikethrough text. When I hovered over it, it said ”'na At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. -Update: I started to do this in the switch.js file. +1. Complete the stretch goals. I started with them on Friday afternoon, which was little bit too late. +2. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. +Update: I started to do this in the switch.js file. -2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. +3. would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. Update: I started to do this in the switch.js file. -4. I would also like to get the "return" to function to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. +4. I would also like to get the "return" to function to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. -4. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. +5. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. ## View it live Netlify link: https://johannas-js-pizzeria.netlify.app/ From f9d30525b69cff2b7dd1415b3ae0eef8a2fdc065 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Fri, 6 Sep 2024 15:42:57 +0200 Subject: [PATCH 23/27] Minor changes --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index abb4b567..5e115671 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ if (mealchoice === 1) { alert(”Thanks, ${name}! You wish to order Pizza!”) } -After a while, I figured it must be because I was using digits, not text. I tested”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using `. So I used ”” for the meal choices (since it has to be only text) and for the alert, I used ` since it has ${name} in it. +After a while, I figured it must be because I was using digits, not text. I tested”, ’ and ´ until I spotted that a backtick/grave/grave accent was used in the first alert that came with the fork. Changed all string/text values to that specific tick and just like that, the code worked. This also made me discover that everything between two quotation marks turns into text, while the ${name} still function when using the backtick. So I used ”” for the meal choices (since it has to be only text) and for the alert, I used ` since it has ${name} in it. ### Old variable? ${name} turned into a strikethrough text. When I hovered over it, it said ”'name' is deprecated.” Googled it, and read that the warning is being shown because the name variable may be removed in future versions. Not sure if it affects my code, but to avoid any issues I changed it to $userName and the strikethough disappeared. @@ -21,15 +21,16 @@ ${name} turned into a strikethrough text. When I hovered over it, it said ”'na At one point when my code didn't work, it was because of a nesting problem. That I couldn't solve myself, because every time I saved the code, it moved to the left-hand side. Asked ChatGPT how to solve this and to fix the nesting issue for me without edit the code itself, and it did. It also asked me to uncheck "formatOnSave" under settings, and I did. ## If I had more time -1. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. -Update: I started to do this in the switch.js file. +1. Complete the stretch goals. I started with them on Friday afternoon, which was little bit too late. +2. Focus more on clean code. I think my code is messy. I had to scroll, search, copy/paste and repeat myself a lot when writing the code. +Update: I started to do this in the switch.js file. -2. I would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. +3. would check if there's a way to avoid repeating different phrases (Like "`Thanks, ${userName}! You wish to order...") and parts of the code. I copy/pasted different sections of my code (like the Pizza else/if to the Pasta and Salad) and did minor changes. It must be an easier way to do this. Update: I started to do this in the switch.js file. -4. I would also like to get the "return" to function in order to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. +4. I would also like to get the "return" to function to stop the script and/or create a loop, so you don't have to start all over when you select a invalid option. -4. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. +5. Maybe add ingredients to the different dishes, that the orderer can deselect? Add more than one dish at the time, etc. ## View it live Netlify link: https://johannas-js-pizzeria.netlify.app/ \ No newline at end of file From 44cf24f2d771ab5aaf80e0c7db11449d26085f22 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Mon, 9 Sep 2024 12:08:13 +0200 Subject: [PATCH 24/27] Changed back to ./script.js --- code/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/index.html b/code/index.html index a0123c31..2030bff0 100644 --- a/code/index.html +++ b/code/index.html @@ -14,7 +14,7 @@

Javascript Pizzeria

Logic is executed automatically

- + \ No newline at end of file From 07db615550f9bd1bea00b7ab4707c7b5c3695312 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson <43312637+joheri1@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:09:33 +0200 Subject: [PATCH 25/27] Update index.html from switch.js to script.js --- code/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/index.html b/code/index.html index a0123c31..e3e8e95f 100644 --- a/code/index.html +++ b/code/index.html @@ -14,7 +14,7 @@

Javascript Pizzeria

Logic is executed automatically

- + - \ No newline at end of file + From 426ae78c5f3b126be69f50c9aae72e753628b87e Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 18 Sep 2024 08:37:04 +0200 Subject: [PATCH 26/27] Add camelCase to the variables don't have that format --- code/script.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/code/script.js b/code/script.js index 8a326a9d..05647f71 100644 --- a/code/script.js +++ b/code/script.js @@ -14,7 +14,7 @@ alert( ) // Step 2 - Food choice -const mealchoice = prompt( +const mealChoice = prompt( `What would you like to order? Please enter the number of your choice. 1. Pizza @@ -23,8 +23,8 @@ const mealchoice = prompt( ` ) //Pizza -if (mealchoice === "1") { - const pizzachoice = prompt( +if (mealChoice === "1") { + const pizzaChoice = prompt( `Thanks, ${userName}! You wish to order Pizza! What type of Pizza you like to order? Please enter the number of your choice. @@ -34,11 +34,11 @@ if (mealchoice === "1") { 3. Vesuvius ` ) - if (pizzachoice === "1") { + if (pizzaChoice === "1") { orderedFood = "Capricciosa pizza" - } else if (pizzachoice === "2") { + } else if (pizzaChoice === "2") { orderedFood = "Hawaii pizza" - } else if (pizzachoice === "3") { + } else if (pizzaChoice === "3") { orderedFood = "Vesuvius pizza" } else { alert("Sorry, we don't have that kind of pizza.") @@ -47,13 +47,13 @@ if (mealchoice === "1") { alert(`You've chosen ${orderedFood}`) } -} else if (mealchoice === "2") { +} else if (mealChoice === "2") { alert( `Thanks, ${userName}! You wish to order Pasta!` ) //Pasta - const pastachoice = prompt( + const pastaChoice = prompt( `What type of Pasta you like to order ? Please enter the number of your choice. 1. Spagetti Bolognese @@ -62,11 +62,11 @@ if (mealchoice === "1") { ` ) - if (pastachoice === "1") { + if (pastaChoice === "1") { orderedFood = "Spagetti Bolognese" - } else if (pastachoice === "2") { + } else if (pastaChoice === "2") { orderedFood = "Pasta Carbonara" - } else if (pastachoice === "3") { + } else if (pastaChoice === "3") { orderedFood = "Fettuccine Alfredo" } else { alert("Sorry, we don't have that kind of pasta.") @@ -75,13 +75,13 @@ if (mealchoice === "1") { alert(`You've chosen ${orderedFood}`) } -} else if (mealchoice === "3") { +} else if (mealChoice === "3") { alert( `Thanks, ${userName}! You wish to order Salad!` ) //Salad - const saladchoice = prompt( + const saladChoice = prompt( `What type of Salad you like to order ? Please enter the number of your choice. 1. Pasta salad @@ -90,11 +90,11 @@ if (mealchoice === "1") { ` ) - if (saladchoice === "1") { + if (saladChoice === "1") { orderedFood = "Pasta salad" - } else if (saladchoice === "2") { + } else if (saladChoice === "2") { orderedFood = "Noodle salad" - } else if (saladchoice === "3") { + } else if (saladChoice === "3") { orderedFood = "Ceaser salad" } else { alert("Sorry, we don't have that kind of salad.") From 936b71cea192d7fb16c3fdcca981928ff13eb689 Mon Sep 17 00:00:00 2001 From: Johanna Eriksson Date: Wed, 18 Sep 2024 09:26:47 +0200 Subject: [PATCH 27/27] Fix: correct indentation in pizza choice section (a comment from code review) --- code/script.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/code/script.js b/code/script.js index 05647f71..55a39db3 100644 --- a/code/script.js +++ b/code/script.js @@ -22,31 +22,33 @@ const mealChoice = prompt( 3. Salad ` ) - //Pizza + +let orderedFood = "" + + // Pizza if (mealChoice === "1") { const pizzaChoice = prompt( - `Thanks, ${userName}! You wish to order Pizza! + `Thanks, ${userName}! You wish to order Pizza! - What type of Pizza you like to order? Please enter the number of your choice. + What type of Pizza you like to order? Please enter the number of your choice. - 1. Capricciosa - 2. Hawaii - 3. Vesuvius - ` - ) - if (pizzaChoice === "1") { - orderedFood = "Capricciosa pizza" - } else if (pizzaChoice === "2") { - orderedFood = "Hawaii pizza" - } else if (pizzaChoice === "3") { - orderedFood = "Vesuvius pizza" - } else { - alert("Sorry, we don't have that kind of pizza.") - } + 1. Capricciosa + 2. Hawaii + 3. Vesuvius + ` + ) + if (pizzaChoice === "1") { + orderedFood = "Capricciosa pizza" + } else if (pizzaChoice === "2") { + orderedFood = "Hawaii pizza" + } else if (pizzaChoice === "3") { + orderedFood = "Vesuvius pizza" + } else { + alert("Sorry, we don't have that kind of pizza.") + } if (orderedFood) { alert(`You've chosen ${orderedFood}`) } - } else if (mealChoice === "2") { alert( `Thanks, ${userName}! You wish to order Pasta!`