user = {
lastName: "Jones",
phone: 12345,
email: "mike@gmail.com",
name: "Mike"
}
for(i = 0; i < Object.keys(user).length; i++) {
theKey = Object.keys(user)[i]
console.log(user.theKey)
}
The current output is:
undefined
undefined
undefined
undefined
expected is:
Jones
12345
mike@gmail.com
Mike
I know there are other ways to do it but I was wondering what my issue was in doing it this way?
Object.keys(user)[i]
returns
lastName
phone
email
name
so I dont understand why it would return undefined in the dot notation. What could I do to return the values of this object in this way?