-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jonas pizza project #152
Open
Jonash189
wants to merge
6
commits into
Technigo:main
Choose a base branch
from
Jonash189:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Jonas pizza project #152
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b9062d7
Added propmt and alert for userName + Added a prompt for the food op…
Jonash189 1bfb54a
Adding subchoice
Jonash189 84c889b
Added age and order confirmation alert
Jonash189 35f6ae2
Adding comments to the code
Jonash189 211af6f
Cleaning the code
Jonash189 4cae938
making space between the diffrent foodchoices. (\n)
Jonash189 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Javascript Pizzeria</title> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" | ||
rel="stylesheet" | ||
/> | ||
</head> | ||
<body> | ||
<h1>Javascript Pizzeria</h1> | ||
<p>Logic is executed automatically</p> | ||
<script src="./script.js"></script> | ||
</body> | ||
</html> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Javascript Pizzeria</title> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" | ||
rel="stylesheet" /> | ||
</head> | ||
|
||
<body> | ||
<h1>Javascript Pizzeria</h1> | ||
<p>Logic is executed automatically</p> | ||
<script src="./script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,98 @@ | ||
// Start here | ||
// Step 1 - The program starts by showing an alert() to welcome the user, and the ordering process begins after they click "OK." | ||
|
||
// 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 Jonas pizza restaurant. When you are ready to order - Click 'OK' to start.`) | ||
|
||
// Step 2 - Food choice | ||
// Your code goes here | ||
// Step 2 - A prompt() asks for the user’s name, and the input is stored in the userName variable, followed by an alert() displaying a personalized greeting. | ||
|
||
// Step 3 - Subtype choice | ||
// Your code goes here | ||
let userName = prompt("Hi there, what's your name?"); | ||
alert(`Hi ${userName}! You'll order your food in the next step.`) | ||
|
||
// Step 4 - Age | ||
// Your code goes here | ||
// This makes the variables accessible throughout the entire program. | ||
let selectedFood; | ||
let subChoice = ""; | ||
|
||
// Step 5 - Order confirmation | ||
// Your code goes here | ||
|
||
// Step 3 - The user selects a main dish (Pizza, Pasta, or Salad) using a prompt(), and the choice is saved in the foodChoice variable. The if-else structure sets the selectedFood variable based on this input. | ||
|
||
let foodChoice = prompt("What kind of food do you want? \n1. Pizza\n2. Pasta\n3. Salad") | ||
|
||
if (foodChoice === "1") { | ||
selectedFood = "Pizza"; | ||
} | ||
else if (foodChoice === "2") { | ||
selectedFood = "Pasta"; | ||
} | ||
else if (foodChoice === "3") { | ||
selectedFood = "Salad"; | ||
} else { | ||
selectedFood = "unknown"; | ||
alert("Error"); | ||
} | ||
|
||
alert(`Thanks, you chose ${selectedFood}!`) | ||
|
||
|
||
// Step 4 - If the user selected a main dish, a prompt() asks for a specific type (e.g., Hawaii for pizza), storing the result in the subChoice variable. The if-else structure determines which subtype is selected or sets subChoice to "Unknown" for invalid inputs. | ||
|
||
if (foodChoice === "1") { | ||
selectedFood = "Pizza"; | ||
|
||
subChoice = prompt("What kind of pizza do you want? \n1. Hawaii \n2. Margarita \n3. Calzone"); | ||
|
||
if (subChoice === "1") { | ||
subChoice = "Hawaii"; | ||
} else if (subChoice === "2") { | ||
subChoice = "Margarita"; | ||
} else if (subChoice === "3") { | ||
subChoice = "Calzone"; | ||
} else { | ||
subChoice = "Unknown pizza"; | ||
alert("Invalid choice"); | ||
} | ||
|
||
} else if (foodChoice === "2") { | ||
selectedFood = "Pasta"; | ||
|
||
subChoice = prompt("What kind of pasta do you want? \n1. Bolognese \n2. Carbonara \n3. Meatballs"); | ||
|
||
if (subChoice === "1") { | ||
subChoice = "Bolognese"; | ||
} else if (subChoice === "2") { | ||
subChoice = "Carbonara"; | ||
} else if (subChoice === "3") { | ||
subChoice = "Meatballs"; | ||
} else { | ||
subChoice = "Unknown pasta"; | ||
alert("Invalid choice"); | ||
} | ||
|
||
} else if (foodChoice === "3") { | ||
selectedFood = "Salad"; | ||
|
||
subChoice = prompt("What kind of salad do you want? \n1. Caesar salad \n2. Chicken salad \n3. Cheese & Ham salad"); | ||
|
||
if (subChoice === "1") { | ||
subChoice = "Caesar salad"; | ||
} else if (subChoice === "2") { | ||
subChoice = "Chicken salad"; | ||
} else if (subChoice === "3") { | ||
subChoice = "Cheese & Ham salad"; | ||
} else { | ||
subChoice = "Unknown salad"; | ||
alert("Invalid choice"); | ||
} | ||
} | ||
|
||
// Step 5 - The program asks the user with a prompt() whether the order is for an adult or child, storing the input in the age variable, and an if-else checks the response. | ||
|
||
let age = prompt("Is this order for an \n1. Adult or \n2. Child?") | ||
|
||
if (age === "1") { | ||
age = "Adult"; | ||
} else if (age === "2") { | ||
age = "Child"; | ||
} | ||
|
||
// Step 6 - An alert() displays a confirmation message combining the userName, subChoice, and age variables to summarize the order. | ||
|
||
alert(`Thank you, ${userName}! You have ordered a ${subChoice} for an ${age}. \nThis will be 150 SEK, you pay at the restaurant. See you soon!`); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we talked about during demo, try to be consistent and declare all variables as the type you expect them to be (so empty string works fine for strings)