6 list'em all SyntaxError: missing } after property list


#1

var friends = {
bill: { firstName: "Bill",
lastName: "li",
number: "(203)-343-4535",
address: ['One Microsoft Way','Redmond','WA','98052']
},

steve: { 
firstName:"Steve",
lastName:"Liu",
number: "(346)-325-3435",
address: ['North street','Redwood','CA','93424']
    }

var list = function(friends) {
for(var steve in friends) {
console.log(steve);
}
}
};


#2

After

steve: { 
firstName:"Steve",
lastName:"Liu",
number: "(346)-325-3435",
address: ['North street','Redwood','CA','93424']
    }

There must be a second closing curly bracket


#3

var friends = {
bill: { firstName: "Bill",
lastName: "li",
number: "(203)-343-4535",
address: ['One Microsoft Way','Redmond','WA','98052']
},

steve: { 
firstName:"Steve",
lastName:"Liu",
number: "(346)-325-3435",
address: ['North street','Redwood','CA','93424']
    }

}

var list = function(friends)
for(var steve in friends) {
console.log(steve);
}

still not working


#4

Now there is no { after function(friends) and no second closing }


#5

I do not understand why is not only STEVE printed?
console.log showed (steve)??
Could you explain it to me?


#6

Maybe this code helps to understand what for in do.

var obj = {a:1, b:2, c:3};
    
for (var prop in obj) {
  console.log("o." + prop + " = " + obj[prop]);
}

// Result:
// "o.a = 1"
// "o.b = 2"
// "o.c = 3"


//FROM MDN