7. Search for friend


#1

Hello, I'm trying to figure out why even though I got the answer right, the output is not specifying the friends contact info. Someone please explain.

var friends={};
friends.bill={
 firstName: 'Asus',
 lastName: 'Seashell',
 number: '(334) 101-5674',
 address: ['213 Headway Rd','Whynot','MS','98320']
};
friends.steve={
 firstName: 'Compaq',
 lastName: 'Presario',
 number: '(443) 271-9042',
 address: ['329 Mt. Ciqu Dr','Granted','WA','72342']
};
friends.hp={
 firstName: 'Hp',
 lastName: 'Pavilian',
 number: '(832) 478-1262',
 address: ['980 Turner Blvd','Peso','OH','89324']
};
var list= function (friends){
  for(var key in friends){
    console.log(key);
  }
};
var search = function(name) {
for (var search in friends) {
console.log(friends[search].firstName);
}
return (friends[search]);
};
search("steve")

#2

i think you managed to fool the validation. currently,

this:

console.log(friends[search].firstName);

should be an if condition, to check if friends[search].firstName equals name (the function parameter), if so, log friends[search] to the console and return it


#3

ok thank you. i will do so


#4

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