Search For a Friend


#1


Ok, so I've been trying to work this out, and I haven't found a solution, unfortunately. Can someone plz tell me what I did wrong here and how is it wrong? Because I've been trying to solve this for a bit of time now. Thanks.

When I try to save and submit this code, it says "Oops, try again. Did you create a function called search?", but I made a function called search.


var friends = new Object();

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

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

friends.bill = new Object();
friends.bill.firstName = "Bill"
friends.bill.lastName = "Gates"
friends.bill.number = "(206) 555-5555"
friends.bill.address = ["Main St", "City", "State"]

friends.steve = new Object();
friends.steve.firstName = "Steve"
friends.steve.lastName = "Jobs"
friends.steve.number = "(408) 555-5555"
friends.steve.address = ["One AM Rd", "City", "State"]

list(friends);
search('Steve');


#2

HI this part

for(var key in friends) {
    if(friends[i].firstname === Bill) {
         console.log(friends[key]);
         return friends[key];
    }
 }

here

if(friends[i].firstname === Bill)

you should put key instead of i inside friends[i] the [] like that friends[key] then firstname should be firstName with the uppercase N to name then instead of Bill you should put name,