Skip to content

Commit bbf0a73

Browse files
author
JorvanW
committed
Updated code and added notes for author.js
1 parent 6c28930 commit bbf0a73

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎Sprint-2/debug/address.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Predict and explain first...
2-
// To specify house number the console.log should use. address.houseNumber.
3-
// without it, It would show as undefined
2+
/* To specify house number the console.log should use. address.houseNumber.
3+
without it, It would show as undefined */
44

55
// This code should log out the houseNumber from the address object
66
// but it isn't working...

‎Sprint-2/debug/author.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
// This program attempts to log out all the property values in the object.
44
// But it isn't working. Explain why first and then fix the problem
55

6+
/* The code wants to log the property value and is using a for...of loop
7+
to make sure it logs everything, however Objects aren't in order and Javascript
8+
doesn't know what you want. Author is an Object and objects are not
9+
iterable which is the error. To fix this change (const value of author) to
10+
(const value of object.values(author)) to specify we want the values (not properties)
11+
in the Object which is 'author'. Using a loop allows up to add information in author
12+
without needing to make changes anywhere else while getting an updated log */
13+
614
const author = {
715
firstName: "Zadie",
816
lastName: "Smith",
@@ -11,6 +19,6 @@ const author = {
1119
alive: true,
1220
};
1321

14-
for (const value of author) {
22+
for (const value of Object.values(author)) {
1523
console.log(value);
1624
}

0 commit comments

Comments
 (0)