Skip to content

Commit 5c03c87

Browse files
committed
correctly log recipe ingredients on separate lines
- Replaced object string output with ingredients joined by newline - Ensures each ingredient is printed on its own line as intended
1 parent 0b3bd51 commit 5c03c87

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sprint-2/debug/recipe.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// Predict and explain first...
2+
// The current console.log outputs ${recipe}, which converts the whole recipe object to a string as "[object Object]".
23

34
// This program should log out the title, how many it serves and the ingredients.
45
// Each ingredient should be logged on a new line
56
// How can you fix it?
67

8+
9+
10+
711
const recipe = {
812
title: "bruschetta",
913
serves: 2,
1014
ingredients: ["olive oil", "tomatoes", "salt", "pepper"],
1115
};
1216

1317
console.log(`${recipe.title} serves ${recipe.serves}
14-
ingredients:
15-
${recipe}`);
18+
ingredients:
19+
${recipe.ingredients.join("\n")}`);

0 commit comments

Comments
 (0)