I'm stuck and don't know where to go from here


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661#


My code doesn't behave incorrectly, I just keep getting this error message, "SyntaxError: missing } after property list


var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ['One Microsoft Way','Redmond','WA','98052']
    }
};
var friends = {
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(610) 406-7987",
        address: ['71 Harry Avenue','Reading','PA','12345'];
    }
};
var list = function (parameter) {
    for (var key in parameter)
    {
        console.log(key);
    }
};
var search = function(name) {
    for(var key in friends) {
        if(friends[key].firstName === name) {
            console.log(friends[key]);
            return friends[key];
        }
    }
};


#2

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ['One Microsoft Way','Redmond','WA','98052']
    }  // here add a , 
}; // here you closed frieds object remove it

so now you dont need next var friends = { // so remove it

now your code should like.....

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555"
        address: ['One Microsoft Way','Redmond','WA','98052']
    },
 steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(610) 406-7987",
        address: ['71 Harry Avenue','Reading','PA','12345'];
    }
};

now you have to call list and search function.


You can add objects directly to friends, like this:

var friends = {
    bill: {},
    steve: {}
};

Or with the bracket ([]) or dot(.) notation, like this:

friends[bill] = {};
friends.steve = {};

Or with Object constructors, like this:

var friends = new Object();

friends.bill = new Object();
friends.steve = new Object();

#3

Thanks for the help!


#4

have you understand now?


#5

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