-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
35 lines (31 loc) · 1.08 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const menuItems = {
appetizers: [
"Bruschetta",
"Caesar Salad",
"Mozzarella Sticks",
],
mainCourses: [
"Spaghetti Carbonara",
"Chicken Alfredo",
"Steak with Mashed Potatoes",
],
desserts: [
"Tiramisu",
"Chocolate Fondue",
"New York Cheesecake",
],
};
const menuSection = document.getElementById("menu");
const appetizersLink = document.getElementById("appetizers-link");
const mainCoursesLink = document.getElementById("main-courses-link");
const dessertsLink = document.getElementById("desserts-link");
appetizersLink.addEventListener("click", () => displayMenu("appetizers"));
mainCoursesLink.addEventListener("click", () => displayMenu("mainCourses"));
dessertsLink.addEventListener("click", () => displayMenu("desserts"));
function displayMenu(category) {
const items = menuItems[category];
const itemList = items.map(item => `<li>${item}</li>`).join("");
menuSection.innerHTML = `<h2>${category}</h2><ul>${itemList}</ul>`;
}
// Display the appetizers by default
displayMenu("appetizers");