-
-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy pathauthor.js
More file actions
20 lines (16 loc) · 588 Bytes
/
author.js
File metadata and controls
20 lines (16 loc) · 588 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Predict and explain first...
// This program attempts to log out all the property values in the object.
// But it isn't working. Explain why first and then fix the problem
const author = {
firstName: "Zadie",
lastName: "Smith",
occupation: "writer",
age: 40,
alive: true,
};
for (const property in author) {
console.log(`${property}:${author[property]}`);
}
/*In this code the problem is that the method for...of is used for array
not for object type instead we use for...in this will work through the object
and list the key and for value We use author[property] */