From afb89220996e721f2ea84ce51f233c04fb3802e2 Mon Sep 17 00:00:00 2001 From: Jenny Date: Mon, 2 Sep 2024 21:28:13 +0200 Subject: [PATCH 1/6] First steps of the pizzeria bot --- code/script.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/code/script.js b/code/script.js index 34ca0f34..6d91a1a8 100644 --- a/code/script.js +++ b/code/script.js @@ -5,12 +5,85 @@ alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) +// Ask the user for their name +const name = prompt("What is your name?"); + +// Display a greeting with their name +alert("Hello " + name + "!"); + // Step 2 - Food choice -// Your code goes here + +const foodChoice = prompt( + "What would you like to order? Please choose a number:\n1. Pizza\n2. Pasta\n3. Salad" +); + +// Display their food of choice + +if (foodChoice === "1") { + alert("You've ordered a pizza!"); +} else if (foodChoice === "2") { + alert("You've ordered pasta!"); +} else if (foodChoice === "3") { + alert("You've ordered a salad!"); +} else { + alert("Invalid choice. Please use a number between 1 and 3"); +} // Step 3 - Subtype choice -// Your code goes here + +if (foodChoice === "1") { +// if the user chooses Pizza + whatKind = promt( + "What kind of Pizza would you like? Please choose a number:\n1. Margherita\n2Pepperoni\n3. Hawaii" + ); + + if (whatKind === "1") { + alert ("You ordered Margherita pizza."); + } else if (whatKind === "2") { + alert ("You ordered Pepperoni pizza."); + } else if (whatKind === "3") { + alert ("You ordered Hawaii pizza."); + } else { + alert ("Unvalid choice") + } + +} else if (foodChoice === "2") { + // if the user chooses Pasta + whatKind = prompt( + "What kind of pasta would you like? Please choose a number:\n1. Vodka pasta\n2Carbonara\n3. Bolognese" + ); + + if (whatKind === "1") { + alert ("You ordered Vodka pasta."); + } else if (whatKind === "2") { + alert ("You ordered Carbonara."); + } else if (whatKind === "3") { + alert ("You ordered Bolognese."); + } else { + alert ("Unvalid choice") + } + +} else if (foodChoice === "3") { + // if the user chooses salad + whatKind = prompt( + "What kind of salad would you like? Please choose a number:\n1. Ceasar salad\n2Greek salad\n3. Tuna salad" + ); + + if (whatKind === "1") { + alert ("You ordered Ceasar salad."); + } else if (whatKind === "2") { + alert ("You ordered Greek salad."); + } else if (whatKind === "3") { + alert ("You ordered Tuna salad."); + } else { + alert ("Unvalid choice") + } + +} else { + alert("Invalid choice. Please use a number between 1 and 3"); +} + // Step 4 - Age // Your code goes here From f7ef980e79c2c8c5151126691d3fd689c6182e0e Mon Sep 17 00:00:00 2001 From: Jenny Date: Sun, 8 Sep 2024 20:38:07 +0200 Subject: [PATCH 2/6] fixed whatKind in order summary --- code/script.js | 101 +++++++++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/code/script.js b/code/script.js index 6d91a1a8..ed6566a6 100644 --- a/code/script.js +++ b/code/script.js @@ -1,25 +1,21 @@ // Start here // Step 1 - Welcome and introduction -// Your code goes here -alert( - `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` -) +alert(`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`); // Ask the user for their name const name = prompt("What is your name?"); // Display a greeting with their name alert("Hello " + name + "!"); - // Step 2 - Food choice - const foodChoice = prompt( "What would you like to order? Please choose a number:\n1. Pizza\n2. Pasta\n3. Salad" ); -// Display their food of choice +let whatKind = ""; // This will store the specific food item +// Display their food of choice if (foodChoice === "1") { alert("You've ordered a pizza!"); } else if (foodChoice === "2") { @@ -31,62 +27,87 @@ if (foodChoice === "1") { } // Step 3 - Subtype choice - if (foodChoice === "1") { -// if the user chooses Pizza - whatKind = promt( - "What kind of Pizza would you like? Please choose a number:\n1. Margherita\n2Pepperoni\n3. Hawaii" + // if the user chooses Pizza + whatKind = prompt( + "What kind of Pizza would you like? Please choose a number:\n1. Margherita\n2. Pepperoni\n3. Hawaii" ); if (whatKind === "1") { - alert ("You ordered Margherita pizza."); + whatKind = "Margherita pizza"; } else if (whatKind === "2") { - alert ("You ordered Pepperoni pizza."); + whatKind = "Pepperoni pizza"; } else if (whatKind === "3") { - alert ("You ordered Hawaii pizza."); + whatKind = "Hawaii pizza"; } else { - alert ("Unvalid choice") + alert("Invalid choice"); } } else if (foodChoice === "2") { // if the user chooses Pasta whatKind = prompt( - "What kind of pasta would you like? Please choose a number:\n1. Vodka pasta\n2Carbonara\n3. Bolognese" + "What kind of pasta would you like? Please choose a number:\n1. Vodka pasta\n2. Carbonara\n3. Bolognese" ); if (whatKind === "1") { - alert ("You ordered Vodka pasta."); - } else if (whatKind === "2") { - alert ("You ordered Carbonara."); - } else if (whatKind === "3") { - alert ("You ordered Bolognese."); - } else { - alert ("Unvalid choice") - } + whatKind = "Vodka pasta"; + } else if (whatKind === "2") { + whatKind = "Carbonara"; + } else if (whatKind === "3") { + whatKind = "Bolognese"; + } else { + alert("Invalid choice"); + } } else if (foodChoice === "3") { - // if the user chooses salad + // if the user chooses Salad whatKind = prompt( - "What kind of salad would you like? Please choose a number:\n1. Ceasar salad\n2Greek salad\n3. Tuna salad" + "What kind of salad would you like? Please choose a number:\n1. Ceasar salad\n2. Greek salad\n3. Tuna salad" ); if (whatKind === "1") { - alert ("You ordered Ceasar salad."); - } else if (whatKind === "2") { - alert ("You ordered Greek salad."); - } else if (whatKind === "3") { - alert ("You ordered Tuna salad."); - } else { - alert ("Unvalid choice") - } - -} else { - alert("Invalid choice. Please use a number between 1 and 3"); + whatKind = "Ceasar salad"; + } else if (whatKind === "2") { + whatKind = "Greek salad"; + } else if (whatKind === "3") { + whatKind = "Tuna salad"; + } else { + alert("Invalid choice"); + } } - // Step 4 - Age -// Your code goes here +// Asks the user for their age +const age = parseInt( + prompt("Is this food for a child or an adult? Type your age:") +); + +let price = ""; +let portionSize = ""; + +if (age) { + if (age <= 10) { + price = "50kr"; + portionSize = "child-sized"; + } else { + price = "100kr"; + portionSize = "adult-sized"; + } +} else { + alert("Invalid entry. Refresh the page and try again"); +} // Step 5 - Order confirmation -// Your code goes here +const orderConfirm = parseInt( + prompt( + `Got it ${name}! One ${portionSize} ${whatKind} is on the way. That will be ${price}.\nPlease confirm your order:\n1. Yes \n2. No` + ) +); + +if (orderConfirm === 1) { + alert(`Thank you ${name} for your order! We are preparing your ${whatKind} now.`); +} else if (orderConfirm === 2) { + alert("That's cool! You are welcome back anytime."); +} else { + alert("Sorry - invalid answer. Please try again!"); +} From 741096237f18d8e85449c5babbdea4108a6a033b Mon Sep 17 00:00:00 2001 From: Jenny Date: Sun, 8 Sep 2024 20:46:59 +0200 Subject: [PATCH 3/6] added whatKind to another message --- .DS_Store | Bin 0 -> 6148 bytes code/script.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..01625912d654f181b4393c80d202bb2d9e546436 GIT binary patch literal 6148 zcmeH~F^LWILo3EBZM)-ySy`wq8Z(Te9ES6D!Ft zGBE%h|QedILw&$at|7ZGN^Z%knsT7a` zZ>E3^r?1nIFO_HO%j)FR3$i9#Co44l2!sp@Qs7?| Fcmh=m5}*J8 literal 0 HcmV?d00001 diff --git a/code/script.js b/code/script.js index ed6566a6..a1302cb9 100644 --- a/code/script.js +++ b/code/script.js @@ -79,7 +79,7 @@ if (foodChoice === "1") { // Step 4 - Age // Asks the user for their age const age = parseInt( - prompt("Is this food for a child or an adult? Type your age:") + prompt(`One ${whatKind} it is! Is this food for a child or an adult? Type your age:`) ); let price = ""; From d87b477857e14c1201acc2af1184c8b7eb56722e Mon Sep 17 00:00:00 2001 From: Jenny Date: Sun, 8 Sep 2024 20:51:57 +0200 Subject: [PATCH 4/6] updated readmefile --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 33c7e601..d92cac40 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ # 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 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? +This project was all about mastering vital yet basic JavaScript concepts like variables, conditionals, and native methods. Technigo created a simple website, so we could can focus solely on JavaScript and nail the basics without distractions. ## 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://jennys-pizza-popups.netlify.app/ \ No newline at end of file From f3f7648ab13aa94c8a7d3fad84b975386bb82713 Mon Sep 17 00:00:00 2001 From: Jenny Date: Mon, 9 Sep 2024 10:17:54 +0200 Subject: [PATCH 5/6] updates in comments --- code/script.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/script.js b/code/script.js index a1302cb9..df817cfd 100644 --- a/code/script.js +++ b/code/script.js @@ -1,7 +1,8 @@ // Start here // Step 1 - Welcome and introduction -alert(`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`); +alert(`Hey stranger! Welcome to our Pizza Popup! Ready to Start? - Click 'OK' to begin.`); + // Ask the user for their name const name = prompt("What is your name?"); @@ -79,11 +80,11 @@ if (foodChoice === "1") { // Step 4 - Age // Asks the user for their age const age = parseInt( - prompt(`One ${whatKind} it is! Is this food for a child or an adult? Type your age:`) + prompt(`One ${whatKind} it is! Is this order for a child or an adult? Type your age:`) ); -let price = ""; -let portionSize = ""; +let price = ""; //stores the price +let portionSize = ""; //stores the portion size (adult/child) if (age) { if (age <= 10) { From af06f340c3bf104d9633390489b1399c7a3c4535 Mon Sep 17 00:00:00 2001 From: Jenny Date: Mon, 9 Sep 2024 10:23:45 +0200 Subject: [PATCH 6/6] moved whatKind variabel --- code/script.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/script.js b/code/script.js index df817cfd..dae8a225 100644 --- a/code/script.js +++ b/code/script.js @@ -14,8 +14,6 @@ const foodChoice = prompt( "What would you like to order? Please choose a number:\n1. Pizza\n2. Pasta\n3. Salad" ); -let whatKind = ""; // This will store the specific food item - // Display their food of choice if (foodChoice === "1") { alert("You've ordered a pizza!"); @@ -28,6 +26,9 @@ if (foodChoice === "1") { } // Step 3 - Subtype choice + +let whatKind = ""; // This will store the specific food item + if (foodChoice === "1") { // if the user chooses Pizza whatKind = prompt(