Contact list exercise with search function


#1



I guess I have figured out the code but the search doesn't seem to provide the properties of the desired friend. I am able to see the firstName correctly however the other Properties do not show up. Any help would be appreciated.


var friends = {};
friends.bill= {
    firstName: "Bill",
    lastName: "Gates",
    number: "(555) 555-5555",
    address: ['One Microsoft Way','Redmond','WA','98052']
};
friends.steve = {
    fristName: "Steve",
    lastName: "Jobs",
    number: "(666) 666-6666",
    address: ['1 Infinite Loop','Cupertino','CA','95014']
};

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

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

list(friends);
search("Steve");


#2

this line:

fristName: "Steve",

you misspelled firstName, thus your steve object doesn't have a firstName property, so it can never be found.


#3

Thanks! That got me through!


#4