Search for a friend - stuck and need help!


#1


Can anyone please help?? Second time i'm posting this up. I don't know what i'm doing wrong???


var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "(555) 104-2984",
        address: ['Candy Street', 'New York', 'NY', '1102'],
    },
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(111) 812-3334",
        address: ['Swirl Road', 'Brooklyn', 'NY', '2966'],
    }
};
    var list = function(friends) {
        for (var firstName in friends) {
        console.log(firstName);
        }
    };
    var search = function(search) {
        for (var key in friends) {
            if(friends[key].firstName === name) {
            console.log(friends[key]);
            return friends[key];
        }
    }
    
}; 
list(friends);
search("Steve");


#2

Hi this line

var search = function(search)

this part

function(search)

change search with name.


#3

Thank you!! Code works now! :grin:


#4

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