We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c87010e commit 0b3bd51Copy full SHA for 0b3bd51
Sprint-2/debug/author.js
@@ -1,4 +1,8 @@
1
// Predict and explain first...
2
+// The code attempts to loop over author using for...of.
3
+// But for...of works on iterable objects like arrays, strings, Maps, Sets.
4
+// Plain objects ({}) are NOT iterable, so for (const value of author) will throw a TypeError:
5
+// author is not iterable.
6
7
// This program attempts to log out all the property values in the object.
8
// But it isn't working. Explain why first and then fix the problem
@@ -11,6 +15,6 @@ const author = {
11
15
alive: true,
12
16
};
13
17
14
-for (const value of author) {
- console.log(value);
18
+for (const key in author) {
19
+ console.log(author[key]);
20
}
0 commit comments