Search for a friend


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/7?curriculum_id=506324b3a7dffd00020bf661


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


var friends= new Object();
friends.bill=new Object();
friends.steve=new Object();
friends.bill={
        firstName: "Bill",
        lastName:"Gates",
        number:"(206) 555-5555",
        address: ['One Microsoft Way','Redmond','WA','98052']
    };

friends.steve = {
  firstName: "Steve",
  lastName: "Jobs",
  number: "(408) 555-5555",
  address: ['1 Infinite Loop','Cupertino','CA','95014']
};   
var list=function(arg){
  for (var key in arg){
    console.log(arg[key])} };
var search=function(name){
    for( var key in friends){
      if (name===friends[key].firstName){
        console.log(friends[key].number,friends[key].address);
        }
      }};
// list(friends);     
search("Steve")


#2

You made Bill and Steve two objects apiece. Also, it may not be absolutely necessary, but please semicolons.


#3

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