7 Oops, try again. It looks like your search function doesn't return contact information for Steve


#1

var friends = {
bill: { firstName: "Bill",
lastName: "li",
number: "(203)-343-4535",
address: ['One Microsoft Way','Redmond','WA','98052']
},

steve: { 
firstName:"Steve",
lastName:"Liu",
number: "(346)-325-3435",
address: ['North street','Redwood','CA','93424']
    }

}

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

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


#2

@textwhiz86979,
object description
search as function
for-in loop explained
http://www.codecademy.com/forum_questions/54a616f9937676fb3d0024c7


#3

i dont understand the problem wth the code, all i get is" Oops, try again.
It looks like your search function doesn't return contact information for Steve." PLEASE HELP

var friends = {};

friends.bill={
firstName: "zack",
lastName: "oloo",
number: "0754337890",
address: ["Nairobi"]

 };

friends.steve={
firstName: "Nancy",
lastName: "wairimu",
number: "07234537890",
address: ["Nairobi"]

 };
var list = function (friends) {

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

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

list(friends);
search("Steve")


#4

//Isso aqui é uma collection JScript
var friends = {
bill : {
firstName: "Bill",
lastName: "Gates",
number: "26153313",
address: ["Rua da banana","São José do Rio Preto","SP","15043"]
},
steve : {
firstName: "Steve",
lastName: "Morse",
number: "56813312",
address: ["Rua do Salame","São José do Rio Preto","SP","15043"]
}
};

//função que percorre a collection
var list = function(item){
for(var friend in friends){
console.log(friend.item);
}
};

var search = function(name){

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

};

This codes runs with no problems.