Skip to content

Commit 89b9b6a

Browse files
committed
I just make my changes by accident in the main branch so I went back and fix it from the original main branch
1 parent 5c03c87 commit 89b9b6a

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

Sprint-2/debug/address.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// The code is trying to log the houseNumber from the address object.
2-
// But it uses address[0], which tries to access the property with key "0".
3-
// Since address is an object with keys like "houseNumber", "street", etc., there is no property 0.
4-
// Therefore, address[0] will be undefined.
5-
// The console will output:
6-
// My house number is undefined
1+
// Predict and explain first...
72

83
// This code should log out the houseNumber from the address object
94
// but it isn't working...
@@ -17,5 +12,4 @@ const address = {
1712
postcode: "XYZ 123",
1813
};
1914

20-
// console.log(`My house number is ${address[0]}`);
21-
console.log(`My house number is ${address.houseNumber}`);
15+
console.log(`My house number is ${address[0]}`);

Sprint-2/debug/author.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// Predict and explain first...
2-
// The code attempts to loop over author using for...of.
3-
// But for...of works on iterable objects like arrays, strings, Maps, Sets.
4-
// Plain objects ({}) are NOT iterable, so for (const value of author) will throw a TypeError:
5-
// author is not iterable.
62

73
// This program attempts to log out all the property values in the object.
84
// But it isn't working. Explain why first and then fix the problem
@@ -15,6 +11,6 @@ const author = {
1511
alive: true,
1612
};
1713

18-
for (const key in author) {
19-
console.log(author[key]);
14+
for (const value of author) {
15+
console.log(value);
2016
}

Sprint-2/debug/recipe.js

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

43
// This program should log out the title, how many it serves and the ingredients.
54
// Each ingredient should be logged on a new line
65
// How can you fix it?
76

8-
9-
10-
117
const recipe = {
128
title: "bruschetta",
139
serves: 2,
1410
ingredients: ["olive oil", "tomatoes", "salt", "pepper"],
1511
};
1612

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

0 commit comments

Comments
 (0)