-
-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathrecipe.js
More file actions
29 lines (21 loc) · 674 Bytes
/
recipe.js
File metadata and controls
29 lines (21 loc) · 674 Bytes
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
// Predict and explain first...
// It is not accessing the ingredients array correctly.
// This program should log out the title, how many it serves and the ingredients.
// Each ingredient should be logged on a new line
// How can you fix it?
const recipe = {
title: "bruschetta",
serves: 2,
ingredients: ["olive oil", "tomatoes", "salt", "pepper"],
};
console.log(`${recipe.title} serves ${recipe.serves}
ingredients:
${recipe.ingredients.join("\n")}`);
// approach 2
// let msg = '';
// for (const ingredient of recipe.ingredients) {
// msg += ingredient + '\n';
// }
// console.log(`${recipe.title} serves ${recipe.serves}
// ingredients:
// ${msg}`);