I can't figure out why this isn't working?


#1


var friends = {};

friends.bill = {
    firstName: "Bill",
    lastName: "Jones",
    number: "(503) -568-2456",
    address: [1234, "La La Lane", 2123]
};
friends.steve = {
    firstName: "Steve",
    lastName: "Smith",
    number: "(808) 221-3944",
    address: [1234, "!@#$%^& Lane", 11392]
};

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

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


#2

Hello @codewhiz66102,

You might want to call friends on list by doing list(friends); and search for firstName by doing search("firstName");


#3

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