diff --git a/README.md b/README.md index 33c7e601..01a7c8e8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # Project Name -Replace this readme with your own information about your project. Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. +This is an javascript pizzeria "machine" built so you can order pizza, pasta or salad online. ## The problem -Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? +It is built mainly with methods like alert() and prompt() and with Conditional statements to tie the answers from the prompts() (that are stored in variables) together. +This was a tought nut to crack and it took a few rounds of thinking (and some help from the team) to get it working. The toughest though I think was how to actually think of the problem before starting to code. I started the coding first and noticed that I had to redo it all almost on every step. Which made me realise the importance of writing down the solution in text first. ## View it live -Have you deployed your project somewhere? Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about +View site: https://js-pizzeria-place.netlify.app/ diff --git a/code/script.js b/code/script.js index 34ca0f34..3585ceeb 100644 --- a/code/script.js +++ b/code/script.js @@ -2,18 +2,126 @@ // Step 1 - Welcome and introduction // Your code goes here +// 1:1 alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) +// 1:2 +let name = prompt("What is your name?"); + +// 1:3 +alert( + `Hello, ${name}!` +) + // Step 2 - Food choice // Your code goes here +let typeOfFood = prompt("We offer the following food:\n1. Pizza\n2. Pasta\n3. Sallad\n\nWhat type of food do you want to order? Type the number of the food."); + +if (typeOfFood === "1") { + alert( + `You have chosen pizza!` + ) +} else if (typeOfFood === "2") { + alert( + `You have chosen pasta!` + ) +} else if (typeOfFood === "3") { + alert( + `You have chosen sallad!` + ) +} + // Step 3 - Subtype choice // Your code goes here +let chooseFoodSub = "" + +if (typeOfFood === "1") { + let choosePizza = prompt("What type of pizza do you want?\n1. Margaritha\n2. Hawaii\n3. Vesuvio"); + if (choosePizza === "1") { + chooseFoodSub = "Margaritha" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } else if (choosePizza === "2") { + chooseFoodSub = "Hawaii" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } else if (choosePizza === "3") { + chooseFoodSub = "Vesuvio" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } +} else if (typeOfFood === "2") { + let choosePasta = prompt("What type of pasta do you want?\n1. Bolognese\n2. Puttanesca\n3. Carbonara"); + if (choosePasta === "1") { + chooseFoodSub = "Bolognese" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } else if (choosePasta === "2") { + chooseFoodSub = "Puttanesca" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } else if (choosePasta === "3") { + chooseFoodSub = "Carbonara" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } +} else if (typeOfFood === "3") { + let chooseSallad = parseInt(prompt("What type of sallad do you want?\n1. Greek\n2. Shrimp\n3. Falafel")) + if (chooseSallad === 1) { + chooseFoodSub = "Greek Salad" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } else if (chooseSallad === 2) { + chooseFoodSub = "Shrimp Salad" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } else if (chooseSallad === 3) { + chooseFoodSub = "Falafel Salad" + alert( + `You have chosen ${chooseFoodSub}!` + ) + } +} + // Step 4 - Age // Your code goes here +let yourAge = parseInt(prompt("Do you want to order a kids or an adult meal? Enter you age below:")) +let confirmOrder = 0 + +if (yourAge <= 12) { + alert( + `You want to order one kids sized portion of our ${chooseFoodSub}!` + ) + confirmOrder = parseInt(prompt("Do you want to confirm your order?\n1. Yes\n2. No")) +} else if (yourAge >= 13) { + alert( + `You want to order one adult sized portion of our ${chooseFoodSub}!` + ) + confirmOrder = parseInt(prompt("Do you want to confirm your order?\n1. Yes\n2. No")) +} + // Step 5 - Order confirmation // Your code goes here + +if (confirmOrder === 1) { + alert( + `Thank you for your order at JavaScript Pizzeria. It will be ready and on its way in 15-20 minutes!` + ) +} else if (confirmOrder === 2) { + alert( + `You have declined your order. But JavaScript Pizzera will be open for you if you change your mind. Hope to see you soon!` + ) +} \ No newline at end of file