Skip to content

Commit 0575f8c

Browse files
authored
Refactor author object and loop structure
Updated author object and changed iteration method to a for loop.
1 parent 5a946c6 commit 0575f8c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎Sprint-2/debug/author.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ for (const value of Object.values(author)) {
3030
}
3131

3232
//we fix this by using Object.values, i.e. turning plain object in an array.
33+
34+
const author = {
35+
firstName: "Zadie",
36+
lastName: "Smith",
37+
occupation: "writer",
38+
age: 40,
39+
alive: true,
40+
};
41+
42+
const keys = Object.keys(author);
43+
44+
for (let i = 0; i < keys.length; i++) {
45+
console.log(author[keys[i]]);
46+
}
47+
48+
//changed it to using "for" loop.

0 commit comments

Comments
 (0)