Skip to content

Commit 8eb363e

Browse files
authored
Fix iteration over author object using Object.values
1 parent 75e4101 commit 8eb363e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Sprint-2/debug/author.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// Predict and explain first...
2+
// The author variable is an object. As such, it is not iterable by default.
3+
// Therefore, using a for...of loop on it throws a TypeError.
24

35
// This program attempts to log out all the property values in the object.
46
// But it isn't working. Explain why first and then fix the problem
@@ -11,6 +13,6 @@ const author = {
1113
alive: true,
1214
};
1315

14-
for (const value of author) {
16+
for (const value of Object.values(author)) {
1517
console.log(value);
1618
}

0 commit comments

Comments
 (0)