diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..391d2801 Binary files /dev/null and b/.DS_Store differ diff --git a/README.md b/README.md index 33c7e601..9fd65722 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # 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. +In this weeks project I was tasked with creating a simple interactive webpage using JavaScript, beginning with displaying a welcome message using the alert() method. Follow the provided steps in the script.js file to guide me through the process of building the project. ## 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? +To approach this problem, I began by carefully reading the provided instructions and analyzing the steps outlined in the script.js file. My initial focus was on understanding how to use the alert() and prompt() method in JavaScript to display messages and store input from a user on the webpage. + +For planning, I followed the sequential steps outlined in the script.js file, breaking down the task into manageable parts. The primary technologies used were JavaScript for adding interactivity with the alert() and prompt() method. If I had more time, my next steps would ipotentially br adding more dynamic elements using JavaScript event listeners and DOM manipulation. + +I also made the strech goals, and in the switch.js file I tried out using ";". And I think I like to use ";" more than not to use them. ## 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://project-pizza-ek.netlify.app diff --git a/code/index.html b/code/index.html index f7844d6b..03209c3a 100644 --- a/code/index.html +++ b/code/index.html @@ -1,18 +1,20 @@ - - - - Javascript Pizzeria - - - - -

Javascript Pizzeria

-

Logic is executed automatically

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

Javascript Pizzeria 🍕

+

Logic is executed automatically

+ + + + \ No newline at end of file diff --git a/code/script.js b/code/script.js index 34ca0f34..ca6a1b14 100644 --- a/code/script.js +++ b/code/script.js @@ -1,19 +1,160 @@ // Start here // Step 1 - Welcome and introduction -// Your code goes here alert( `Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.` ) +let userName = prompt( + `What is your name?` +) + +alert( + `Hello ${userName}!` +) + // Step 2 - Food choice -// Your code goes here +let foodChoice = prompt( + `What kind of food would you like to order? + Enter a number: + 1 - Pizza + 2 - Pasta + 3 - Salad + ` +) + +let foodName + +if (foodChoice === `1`) { + foodName = `Pizza` +} else if (foodChoice === `2`) { + foodName = `Pasta` +} else if (foodChoice === `3`) { + foodName = `Salad` +} else { + foodName = `no food` +} + +alert( + `You have chosen ${foodName}. Yum!` +) // Step 3 - Subtype choice -// Your code goes here +let subType + +if (foodChoice === `1`) { + subType = prompt( + `What kind of Pizza would you like to order? + Enter a number: + 1 - Margeritha + 2 - Napolitana + 3 - Bussola + ` + ) + + if (subType === `1`) { + subType = `Margeritha` + } else if (subType === `2`) { + subType = `Napolitana` + } else if (subType === `3`) { + subType = `Bussola` + } else { + subType = `no food` + } + +} else if (foodChoice === `2`) { + subType = prompt( + `What kind of Pasta would you like to order? + Enter a number: + 1 - Arrabiata + 2 - Garlic + 3 - Meat and sauce + ` + ) + + if (subType === `1`) { + subType = `Arrabiata` + } else if (subType === `2`) { + subType = `Garlic` + } else if (subType === `3`) { + subType = `Meat and sauce` + } else { + subType = `no food` + } + +} else if (foodChoice === `3`) { + subType = prompt( + `What kind of Salad would you like to order? + Enter a number: + 1 - Tuna + 2 - Ham and cheese + 3 - Veggi + ` + ) + + if (subType === `1`) { + subType = `Tuna` + } else if (subType === `2`) { + subType = `Ham and cheese` + } else if (subType === `3`) { + subType = `Veggi` + } else { + subType = `no food` + } + +} else { + subType = `no food` +} + +alert( + `You have chosen ${subType}. Yum!` +) // Step 4 - Age -// Your code goes here +let userAge = prompt( + `Is this food for a child or an adult? + Please type your age:` +) + +//Step 5 - Order confirmation +let confirmation + +if (userAge <= 12) { + confirmation = prompt( + `You'd like to order a child portion of ${subType}. + - price $7 + + Are you sure you want to order this? + Enter a number to confirm: + 1 - Yes + 2 - No + ` + ) + +} else { + confirmation = prompt( + `You'd like to order an adult portion of ${subType}. + - price $10 + + Are you sure you want to order this? + Enter a number to confirm: + 1 - Yes + 2 - No + ` + ) +} + +if (confirmation === `1`) { + alert( + `Thank you for your order, your food is now being prepared` + ) +} else if (confirmation === `2`) { + alert( + `Your order has been canceled, please return for future orders` + ) -// Step 5 - Order confirmation -// Your code goes here +} else { + alert( + `Your order has ben canceled due to a type error, please return for future orders` + ) +} \ No newline at end of file diff --git a/code/switch.js b/code/switch.js new file mode 100644 index 00000000..afbb87d1 --- /dev/null +++ b/code/switch.js @@ -0,0 +1,160 @@ +// Step 1 - Welcome and introduction +alert(`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`); + +let userName = prompt(`What is your name?`); +alert(`Hello ${userName}!`); + +// Step 2 - Food choice +let foodChoice = prompt( + `What kind of food would you like to order? + Enter a number: + 1 - Pizza + 2 - Pasta + 3 - Salad + ` +); + +let foodName; + +switch (foodChoice) { + case `1`: + foodName = `Pizza`; + break; + case `2`: + foodName = `Pasta`; + break; + case `3`: + foodName = `Salad`; + break; + default: + foodName = `no food`; +} + +alert(`You have chosen ${foodName}. Yum!`); + +// Step 3 - Subtype choice +let subType; + +switch (foodChoice) { + case `1`: + subType = prompt( + `What kind of Pizza would you like to order? + Enter a number: + 1 - Margherita + 2 - Napolitana + 3 - Bussola + ` + ); + + switch (subType) { + case `1`: + subType = `Margherita`; + break; + case `2`: + subType = `Napolitana`; + break; + case `3`: + subType = `Bussola`; + break; + default: + subType = `no food`; + } + break; + + case `2`: + subType = prompt( + `What kind of Pasta would you like to order? + Enter a number: + 1 - Arrabiata + 2 - Garlic + 3 - Meat and sauce + ` + ); + + switch (subType) { + case `1`: + subType = `Arrabiata`; + break; + case `2`: + subType = `Garlic`; + break; + case `3`: + subType = `Meat and sauce`; + break; + default: + subType = `no food`; + } + break; + + case `3`: + subType = prompt( + `What kind of Salad would you like to order? + Enter a number: + 1 - Tuna + 2 - Ham and cheese + 3 - Veggi + ` + ); + + switch (subType) { + case `1`: + subType = `Tuna`; + break; + case `2`: + subType = `Ham and cheese`; + break; + case `3`: + subType = `Veggi`; + break; + default: + subType = `no food`; + } + break; + + default: + subType = `no food`; +} + +alert(`You have chosen ${subType}. Yum!`); + +// Step 4 - Age +let userAge = prompt(`Is this food for a child or an adult? Please type your age:`); + +// Step 5 - Order confirmation +let confirmation; + +if (userAge <= 12) { + confirmation = prompt( + `You'd like to order a child portion of ${subType}. + - price $7 + + Are you sure you want to order this? + Enter a number to confirm: + 1 - Yes + 2 - No + ` + ); +} else { + confirmation = prompt( + `You'd like to order an adult portion of ${subType}. + - price $10 + + Are you sure you want to order this? + Enter a number to confirm: + 1 - Yes + 2 - No + ` + ); +} + +// Switch for confirmation +switch (confirmation) { + case `1`: + alert(`Thank you for your order, your food is now being prepared`); + break; + case `2`: + alert(`Your order has been canceled, please return for future orders`); + break; + default: + alert(`Your order has been canceled due to a type error, please return for future orders`); +} \ No newline at end of file