Skip to content

Commit cf51180

Browse files
committed
add authors.js
1 parent 2982e93 commit cf51180

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎Sprint-2/debug/author.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
// Predict and explain first...
2+
// TypeError: author is not iterable because A for...of loop is used for iterable things such as arrays, strings, Maps, and Sets.
3+
4+
// But author is a plain object. Plain objects aren't directly iterable with for...of.
5+
6+
// To loop through an object's values, use:
27

38
// This program attempts to log out all the property values in the object.
49
// But it isn't working. Explain why first and then fix the problem
5-
610
const author = {
711
firstName: "Zadie",
812
lastName: "Smith",
@@ -11,6 +15,6 @@ const author = {
1115
alive: true,
1216
};
1317

14-
for (const value of author) {
18+
for (const value of Object.values(author)) {
1519
console.log(value);
16-
}
20+
}

0 commit comments

Comments
 (0)