Skip to content

Commit 2dbe395

Browse files
authored
Fix author iteration by using Object.entries
1 parent b10547d commit 2dbe395

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎Sprint-2/debug/author.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
// I think the issue with the original code is it was trying to loop over the object directly,
77
// which is not iterable. Instead, we should loop over the array that contains the object.
88

9-
const author = [
9+
const author =
1010
{
1111
firstName: "Zadie",
1212
lastName: "Smith",
1313
occupation: "writer",
1414
age: 40,
1515
alive: true,
16-
},
17-
];
16+
}
1817

19-
for (const value of author) {
20-
console.log(value);
18+
for (let [key, value] of Object.entries(author)) {
19+
console.log(key, value);
2120
}

0 commit comments

Comments
 (0)