7. search for a friend


#1

Not sure what the issue is with my code. It keeps saying there was a problem with my syntax. Please help!

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(414) 564-8987",
address: ["One Microsoft Way", "Redmond", "WA", "98052"]
}
steve: {
firstName: "Steve",
lastName: "Gate",
number: "(414) 564-8977",
address: ["Three Microsoft Rd", "Milwaukee", "WI", "53216"]
}
};

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

};

var search = function(name) {
for(var key in friends) {
if(friends[key]firstName === name) {
console.log(friends[key]);
return friends[key];
}
}
};


#2

The only thing that I can see is the line where you have friends[key]firstname; you should have a period before firstname so that it shows friends[key].firstname.


#3

It still says I have an unexpected identifier. This is probably the only thing holding me back from passing this section.


#4

Nvm I solved the issue. :slightly_smiling: