Skip to content

Commit cf24d94

Browse files
committed
Completed Sprint2-debug
1 parent 8eb514b commit cf24d94

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

Sprint-2/debug/address.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// but it isn't working...
55
// Fix anything that isn't working
66

7+
// i predict that it will fail straight away as value for houseNumber was not in a string
78
const address = {
89
houseNumber: 42,
910
street: "Imaginary Road",
@@ -12,4 +13,6 @@ const address = {
1213
postcode: "XYZ 123",
1314
};
1415

15-
console.log(`My house number is ${address[0]}`);
16+
console.log(`My house number is ${address.houseNumber}`);
17+
18+
// the issue was that it was looking for the property [0] so i changed it to dot notation .houseNumber in the console.log

Sprint-2/debug/author.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const author = {
1111
alive: true,
1212
};
1313

14-
for (const value of author) {
14+
for (const value of Object.values(author)) {
1515
console.log(value);
1616
}
17+
// Objects are not iterable, so for...of can’t be used on them unless you convert them to an array (e.g. with Object.values).

Sprint-2/debug/recipe.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// Each ingredient should be logged on a new line
55
// How can you fix it?
66

7+
// it should print the recipe title, how many people people it serves and lists the ingredients.
8+
79
const recipe = {
810
title: "bruschetta",
911
serves: 2,
@@ -12,4 +14,6 @@ const recipe = {
1214

1315
console.log(`${recipe.title} serves ${recipe.serves}
1416
ingredients:
15-
${recipe}`);
17+
${recipe.ingredients.join(",")}`);
18+
19+
// it printed [object Object], this is because ${recipe} tries to print the whole object, which shows as [object Object] instead of useful data. This was fixed by using ${recipe.ingredients} (and .join(", ")) to display the ingredients properly.

0 commit comments

Comments
 (0)