From b4b4ef04e020dd242a5287da7141af8424c78bcd Mon Sep 17 00:00:00 2001 From: Cholpon Date: Sun, 8 Sep 2024 21:51:52 +0200 Subject: [PATCH 1/3] completed all steps --- .vscode/settings.json | 3 ++ code/script.js | 109 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6f3a2913 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/code/script.js b/code/script.js index 34ca0f34..8a78f092 100644 --- a/code/script.js +++ b/code/script.js @@ -1,19 +1,120 @@ // Start here // Step 1 - Welcome and introduction -// Your code goes here alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) +// prompt to ask for the name and store the answer in a variable +const guestName = prompt('Please enter your name') +alert('Hi ' + guestName + '!') // Step 2 - Food choice -// Your code goes here +// allow the user to select the type of food they want to order + +const foodChoice = prompt('What type of food would you like to order?\Please enter a number:\ 1 - Pizza 2 - Pasta 3 - Salad'); + +if (foodChoice === '1') { + alert('You have chosen Pizza!') +} else if (foodChoice === '2') { + alert('You have chosen Pasta!') +} +else if (foodChoice === '3') { + alert('You have chosen Salad!') +} +else { + alert('Invalid choice. Please select a number between 1 and 3.') +} // Step 3 - Subtype choice // Your code goes here +// Pizza subtype +if (foodChoice === '1') { + const pizzaType = prompt('Select a Pizza type! \ Enter a number:\ 1 - Margherita 2 - Pepperoni 3 - Hawaiian') + + if (pizzaType === '1') { + alert('You have chosen Margherita!') + selectedFoodType = 'Margherita' + } else if (pizzaType === '2') { + alert('You have chosen Pepperoni!') + selectedFoodType = Pepperoni + } + else if (pizzaType === '3') { + alert('You have chosen Hawaiian!') + selectedFoodType = 'Hawaiian' + } + else { + alert('Invalid choice. Please select a number between 1 and 3.') + } +} + + +// Pasta subtype + +if (foodChoice === '2') { + const pastaType = prompt('Select a Pasta type! Enter a number: 1 - Spaghetti Carbonara: 2 - Pasta Bolognese 3 - Pasta Alfredo') + + if (pastaType === '1') { + alert('You have chosen Spaghetti Carbonara!') + selectedFoodType = 'Spaghetti Carbonara' + } else if (pastaType === '2') { + alert('You have chosen Pasta Bolognese!') + selectedFoodType = 'Pasta Bolognese' + } + else if (pastaType === '3') { + alert('You have chosen Pasta Alfredo!') + selectedFoodType = 'Pasta Alfredo' + } + else { + alert('Invalid choice. Please select a number between 1 and 3.') + } +} + +//Salad subtype + +if (foodChoice === '3') { + const saladType = prompt('Select a Salad type! Enter a number: 1 - Caesar Salad 2 - Garden Salad 3 - Greek Salad') + + if (saladType === '1') { + alert('You have chosen Caesar Salad!') + selectedFoodType = 'Ceaser Salad' + } else if (saladType === '2') { + alert('You have chosen Garden Salad!') + selectedFoodType = 'Garden Salad' + } + else if (saladType === '3') { + alert('You have chosen Greek Salad!') + selectedFoodType = 'Greek Salad' + } + else { + alert('Invalid choice. Please select a number between 1 and 3.') + } +} + // Step 4 - Age -// Your code goes here +const guestAge = prompt('Is this food for a child or an adult? Type your age:') +const age = Number(guestAge); + +let finalPrice; +if (guestAge >= '13') { + // Adult + finalPrice = 15; + alert(`One ${selectedFoodType} will be prepared for you. That'll be €15.`); +} +else { + //Child + finalPrice = 10; + alert(`One child sized ${selectedFoodType} will be prepared for you. That'll be €10.`); +} // Step 5 - Order confirmation -// Your code goes here + +const confirmation = prompt(`Would you like to confirm your order? Type 'yes' or 'no'.`) + +if (confirmation === 'yes') { + alert('Thank you! Your meal will be prepared shortly. The total cost is ' + finalPrice + '€') +} +else { + alert('We hope to see you again soon!'); +} + From 4a40cc7586ce7b18d97ff961667828f59912ef82 Mon Sep 17 00:00:00 2001 From: Cholpon <127111343+cholpoun@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:58:17 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 33c7e601..57c2d1d4 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. +Built a JavaScript Pizzeria +Mastering vital yet basic JavaScript concepts like variables, conditionals, and native methods. ## The problem -Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? +I used JavaScript concepts like variables, conditionals, and native methods. ## View it live -Have you deployed your project somewhere? Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about +https://66de0156d116e596d11ff09e--coruscating-basbousa-190b83.netlify.app/ From 387920e956e8c7217ea84ead1c12e2b957f9aa8c Mon Sep 17 00:00:00 2001 From: Cholpon <127111343+cholpoun@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:27:48 +0200 Subject: [PATCH 3/3] Made requested changes --- code/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/script.js b/code/script.js index 8a78f092..ceb6e1e3 100644 --- a/code/script.js +++ b/code/script.js @@ -37,7 +37,7 @@ if (foodChoice === '1') { selectedFoodType = 'Margherita' } else if (pizzaType === '2') { alert('You have chosen Pepperoni!') - selectedFoodType = Pepperoni + selectedFoodType = 'Pepperoni' } else if (pizzaType === '3') { alert('You have chosen Hawaiian!') @@ -92,11 +92,11 @@ if (foodChoice === '3') { } // Step 4 - Age -const guestAge = prompt('Is this food for a child or an adult? Type your age:') -const age = Number(guestAge); +const userInputAge = prompt('Is this food for a child or an adult? Type your age:') +const ageConvertedToNumber = Number(userInputAge); let finalPrice; -if (guestAge >= '13') { +if (userInputAge >= '13') { // Adult finalPrice = 15; alert(`One ${selectedFoodType} will be prepared for you. That'll be €15.`);