Skip to content
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

Javascript project-pizza #143

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 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.
Introduction to javascript and use of alert messages and prompt method for a simple food ordering page.

## 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?
tt was my first time using javascript so the challenge was mainly in understanding and learning the basics. The problems I ran into were mainly getting the conditional statements right, but doing to the project step by step made it easier to solve the problems along the way.

## 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://gilded-marzipan-59036d.netlify.app/
Binary file added code/.DS_Store
Binary file not shown.
19 changes: 0 additions & 19 deletions code/script.js

This file was deleted.

File renamed without changes.
124 changes: 124 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@

// Step 1 - Welcome and introduction
alert(
`Welcome to our Javascript Pizzeria. Ready to Start? - Click 'OK' to begin.`
);

// b) user's name using the prompt
let name = prompt("What is your name?");

// c) alert using the name variable to greet the user
alert(
`Hi, ${name}!`
);


// Step 2 - Food choice
let choice = prompt("What food would you like to order?\n1. Pizza\n2. Pasta\n3. Salad\nEnter a number:");
let foodType;
if (choice === "1") {
foodType = "Pizza";
} else if (choice === "2") {
foodType = "Pasta";
} else if (choice === "3") {
foodType = "Salad";
} else {
foodType = null;
}
//alert message for choice of food
if (foodType) {
alert(`You have selected ${foodType}.`);
} else {
alert("Invalid choice. Please try again.");
}

// Step 3 - Subtype choice
let subtype;

// Pizza subtypes
if (foodType === "Pizza") {
subtype = prompt("Please choose a Pizza type:\n1. Margherita\n2. Capricciosa\n3. Marinara\nPlease enter a number:");

if (subtype === "1") {
subtype = "Margherita";
} else if (subtype === "2") {
subtype = "Capricciosa";
} else if (subtype === "3") {
subtype = "Marinara";

//alert message for subtype of pizza
} else {
alert("Invalid choice. Please refresh and try again.");
}
alert(`You have selected ${subtype}.`);
}

// Pasta subtypes
else if (foodType === "Pasta") {
subtype = prompt("Please choose a Pasta type:\n1. Carbonara\n2. Arrabiata\n3. Bolognese\nPlease enter a number:");

if (subtype === "1") {
subtype = "Carbonara";
} else if (subtype === "2") {
subtype = "Arrabiata";
} else if (subtype === "3") {
subtype = "Bolognese";

//alert message for subtype of pasta
} else {
alert("Invalid choice. Please refresh and try again.");
}
if (subtype) {
alert(`You have selected ${subtype}.`);
}
}

// Salad subtypes
else if (foodType === "Salad") {
subtype = prompt("Please choose a Salad type:\n1. Greek salad\n2. Salad Nicoise \n3. Caesar salad\nPlease enter a number:");

if (subtype === "1") {
subtype = "Greek salad";
} else if (subtype === "2") {
subtype = "Salad Nicoise";
} else if (subtype === "3") {
subtype = "Caesar salad";
}
//alert message for subtype of salad
alert(`You have selected ${subtype}.`);
} else {
alert("Invalid choice. Please refresh and try again.");
}

// Step 4 - Age
let age = prompt("Is this food for a child or an adult? Please type your age:");
let ageGroup, cost;

if (age < 16) {
ageGroup = "Child";
cost = "€8.00";
} else if (age >= 16) {
ageGroup = "Adult";
cost = "€10.00";

//alert message for age and cost
} else {
alert("Invalid age entered. Please try again.");
}
if (ageGroup && cost) {
alert(`You have selected food for a ${ageGroup}. The cost will be ${cost}.`);
}

// Step 5 - Order confirmation
if (ageGroup && foodType && subtype) {
let orderDetails = `You are about to order a ${foodType} (${subtype}) for a ${ageGroup}. The cost will be ${cost}. Would you like to confirm your order?`;
let confirmation = prompt(`${orderDetails}\n1. Yes\n2. No\nPlease enter a number:`);

if (confirmation === "1") {
alert("Thank you! Your meal will be prepared shortly.");
} else if (confirmation === "2") {
alert("Thank you for visiting! We hope to see you again soon.");
} else {
alert("Invalid choice. Please refresh the page and try again.");
}
}
File renamed without changes.