Skip to content

Commit 6de1246

Browse files
committed
debug logging the values of an object
1 parent 6a0643a commit 6de1246

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎Sprint-2/debug/author.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// Predict and explain first...
2+
// author is an object. It cannot be accessed through its values, maybe through its key, value pairs instead of "value" -
3+
4+
//update on explanation: objects could be accessed through 3 methods, depending on whether we want the property name or property value, or the pair. :
5+
//1. Object.keys() collects into an array the keys (property names) ignoring the values
6+
//2. Object.values() collects into an array the values ignoring the property names
7+
//3. Object.entries() collects an array of arrays of key-value pairs
28

39
// This program attempts to log out all the property values in the object.
410
// But it isn't working. Explain why first and then fix the problem
@@ -11,6 +17,7 @@ const author = {
1117
alive: true,
1218
};
1319

14-
for (const value of author) {
15-
console.log(value);
16-
}
20+
console.log(Object.values(author));
21+
// for (const value of author) {
22+
// console.log(value);
23+
// }

0 commit comments

Comments
 (0)