6/8 how can we do it with constructor method


#1

var friends = new Object()
friends.bill= {firstName:"Bill",lastName:"Gate",number:4543,address:["on Microsoft"]};
friends.steve=firstName:"Steve",lastName:"Jobs",number:34355,address:["on Apple"]

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


#2

You didn't enclosed your object steve the same way than bill. Forgot curly brackets { } and semi colons.
here the fix :smile:

    var friends = new Object();
    
    friends.bill= {firstName:"Bill",lastName:"Gate",number:4543,address:["on Microsoft"]};
    friends.steve= {firstName:"Steve",lastName:"Jobs",number:34355,address:["on Apple"]};
    
    function list (name){
    for (var key in friends ){
         if (friends[key].firstName === name){
            console.log(friends[key]);
            return (friends[key]);
            }
         }
      }
    list ("Steve");