Why I get "undefined"

var people = [
    {name: "test1", picture: ""},
    {name: "test2", picture: ""},
    {name: "test3", picture: ""},
    {name: "test4", picture: ""},
    {name: "test5", picture: ""},
    {name: "test6", picture: ""}

It should return test1. But instead it gives me undefined. I don’t understand why.

people[0].name isn’t undefined, but return value of console.log is.

1 Like

How I can fix that? Cause it doesn’t seem right to me.

@Daw588 can you post your whole code? As from your code, I guess it should return test1.

image that’s my full code

Whatever I try to console.log() it will always return undefined.

That’s really weird. I ran the same code and got

<-  undefined

on Mozilla and Chrome. Maybe the site on which you’re console logging might have hacked with console class.

I tried this on discord.com, google.com, and support.glitch.com. Same results. NVM. I was on “errors” section instead of “user-messages”.

1 Like