Search for a friend


#1

It does not work. Why?

var friends= {
bill:{
firstName: "Bill",
lastName:"Marques",
number: "3206317764",
address:["calle 39A , n36b32"]

},
steve:{
    firstName:"Steve",
    lastName:"Torres",
    number:"423585298",
    address:["one microsoft street, street 12, 4958"]
        }

};

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

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");


#2

This line is not needed in the list() function. It may be removed. There is another issue with the line... friend is not defined. However, no matter. Not needed.

There should be no white space between friends and [.


#3

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