4. What syntax am I getting wrong?


#1

So I understand objects, however, placing this into the interpreter gives me a syntax error. What am I doing wrong?

var friends = {
bill: {
firstName: "Bill",
lastName: "Smith",
number: "12"
}
steve: {

    firstName: "Steve",
    lastName: "Andersmith",
    number: "13"   
}
};

#2

You want to have your first object (var friends) to be empty. Don't nest everything inside of your friends variable because you add your friends in using dot notation. So instead of having var friends = { bill:{ } }; You add them in using friends.bill = { }


#3

Hm. So between the two of them, is using dot notation more efficient when constructing objects? It's probably not as black and white, but would nesting objects ever be a more useful way of using objects?


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.