Skip to content

Commit b7494f7

Browse files
authored
Fix iteration method for author object
Replaced for...in loop with for...of loop to iterate over author object values.
1 parent 637ccab commit b7494f7

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎Sprint-2/debug/author.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ const author = {
1111
alive: true,
1212
};
1313

14-
for (const key in author) {
15-
console.log(author[key]);
14+
for (const value of author) {
15+
console.log(value);
1616
}
17-
18-
//TypeError: author is not iterable
19-
// The for...of loop only works on iterable objects in JavaScript—such as Arrays, Strings, Sets, and Maps.
20-
// Plain JavaScript objects ({}) are not iterable by default because they don't have a built-in [Symbol.iterator] method.
21-
// use a for...in loop to step through the keys, then access each value using bracket notation

0 commit comments

Comments
 (0)