-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestaurant_menu.js
31 lines (22 loc) · 1.07 KB
/
restaurant_menu.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
const breakfastMenu = ["Pancakes", "Eggs Benedict", "Oatmeal", "Frittata"];
const mainCourseMenu = ["Steak", "Pasta", "Burger", "Salmon"];
const dessertMenu = ["Cake", "Ice Cream", "Pudding", "Fruit Salad"];
// this converts breakfast menu array items into HTML strings using map().
const breakfastMenuItemsHTML = breakfastMenu
.map((item, index) => `<p>Item ${index + 1}: ${item}</p>`)
.join("");
console.log(breakfastMenuItemsHTML);
document.getElementById("breakfastMenuItems").innerHTML =
breakfastMenuItemsHTML;
// this converts breakfast menu array items into HTML strings using forEach().
let mainCourseItem = "";
mainCourseMenu.forEach((item, index) => {
mainCourseItem += `<p>Item ${index + 1}: ${item}</p>`;
});
document.getElementById("maincourseMenuItems").innerHTML = mainCourseItem;
// this converts breakfast menu array items into HTML strings using for loop.
let dessertItem = "";
for (let i = 0; i < dessertMenu.length; i++) {
dessertItem += `<p>Item ${i + 1}: ${dessertMenu[i]}</p>`;
}
document.getElementById("dessertMenuItems").innerHTML = dessertItem;