Contact list


#1

dont know what is wrong with my code.

var friends={
bill: {
firstName:'Bill',
lastName:'Gates',
number: '(206) 555-5555',
address:['One Microsoft','Redmond','WA','98052'],
},
steve: {
firstName:'Bill',
lastName:'Gates',
number:'(205) 666-6666',
address:['two','luk','LA','00000'],
},
};
var list=function(friends) {
for(var key in friends) {
console.log(key);
}
}
var search= function(name) {
for(var key in friends) {
if(friends[key].firstName===name) {
console.log(friends[key]);
return friends[key];
}
};

    }

#2

@aftal2,

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

#3

i cant see the difference between your code and mine


#4

@aftal2,
Yes that is correct...

The problem will be that the code-checker
is expecting a bill- and a steve-object
in your friends-object
like

var friends= {
              bill: { firstName: 'Bill',
                      lastName: 'Gates',
                      number: '444-444-4444',
                      address: [ 'One Microsoft way', 'Redwood', 'WA' ]
              },
             steve: {
                      firstName: 'Steve',
                      lastName: 'Jobs',
                      number: '333-333-3333',
                      address: [ 'Two infinite loop', 'Bentown', 'DV' ] 
              }
   };