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/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/ diff --git a/code/script.js b/code/script.js index 34ca0f34..ceb6e1e3 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 userInputAge = prompt('Is this food for a child or an adult? Type your age:') +const ageConvertedToNumber = Number(userInputAge); + +let finalPrice; +if (userInputAge >= '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!'); +} +