What should be the o/p for the given code?I am getting both 'Bill' n 'Steve' info as o/p?


#1

var friends = {};
friends.bill = {
firstName : 'Bill',
lastName : 'Pereira',
number : 554444,
address : ['9','Park Street','Vasai','401202'],

};
friends.steve = {
    firstName : 'Steve',
    lastName : 'Fernandes',
    number : 99937473,
    address : ['202/2','Cupertino','Naigaon','401303'],

    };
    var list = function(obj)
    {
       for(var prop in obj){
           console.log(prop);

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

list(friends);
search("Steve");


#2

Hey @anushree27! One problem i spot in your code is that when you initalize your Arrays dont do

friends.steve{
then code here
}

Instead this:

var steve{
then code here
};

tell me if thier are any additonal problems


#3

I have a doubt.If I am writing 'var steve',how will I access 'friends' object?Can you please explain clearly?