diff --git a/Sprint-2/debug/address.js b/Sprint-2/debug/address.js index 940a6af83..65c3b5ecd 100644 --- a/Sprint-2/debug/address.js +++ b/Sprint-2/debug/address.js @@ -1,5 +1,5 @@ // Predict and explain first... - +// i think its because the address is not used as an array but as an object // This code should log out the houseNumber from the address object // but it isn't working... // Fix anything that isn't working @@ -12,4 +12,4 @@ const address = { postcode: "XYZ 123", }; -console.log(`My house number is ${address[0]}`); +console.log(`My house number is ${address.houseNumber}`); diff --git a/Sprint-2/debug/author.js b/Sprint-2/debug/author.js index 8c2125977..2a37e796d 100644 --- a/Sprint-2/debug/author.js +++ b/Sprint-2/debug/author.js @@ -1,8 +1,8 @@ // Predict and explain first... - +//i think its because value is not used as a parameter of an object, and author is an object not an ordered list Array. // This program attempts to log out all the property values in the object. // But it isn't working. Explain why first and then fix the problem - +// i found that object literals are not iterative because they have no orders const author = { firstName: "Zadie", lastName: "Smith", @@ -11,6 +11,6 @@ const author = { alive: true, }; -for (const value of author) { +for (const value of Object.values(author)) { console.log(value); } diff --git a/Sprint-2/debug/recipe.js b/Sprint-2/debug/recipe.js index 6cbdd22cd..8b6bca89a 100644 --- a/Sprint-2/debug/recipe.js +++ b/Sprint-2/debug/recipe.js @@ -1,5 +1,9 @@ // Predict and explain first... - +/* +console.log(`${recipe.title} serves ${recipe.serves} + ingredients: +${recipe}`);// here it misses recipe.ingredients +*/ // 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? @@ -12,4 +16,4 @@ const recipe = { console.log(`${recipe.title} serves ${recipe.serves} ingredients: -${recipe}`); +${recipe.ingredients.join("\n")}`); // this make the list to be logged on a new line - not predicted at first