Could someone help me pls


#1

6/8 contact list objects and arrays

"Oops, try again. It looks like your list function isn't printing the right output."

var friends ={
    bill: {
        firstName: 'Bill',
        lastName: 'Gates',
        number:'(206) 555-5555',
        address: ['One Microsoft Way','Redmond','WA','98052']
        },
    steve: {
        firstName: 'Steve',
        lastName: 'Jobs',
        number:'(206) 555-5555',
        address: ['One apple street','Redmond','WA','98052']
        }
    
    };

var list = function(friends){
    for(var i in friends);
    console.log(friends[i]);
    };


#2

generally for in loop syntax:

for (iterator in object){

}

the {} of your for in your loop missing.


#3

var friends ={
bill: {
firstName: 'Bill',
lastName: 'Gates',
number:'(206) 555-5555',
address: ['One Microsoft Way','Redmond','WA','98052']
},
steve: {
firstName: 'Steve',
lastName: 'Jobs',
number:'(206) 555-5555',
address: ['One apple street','Redmond','WA','98052']
}

};

var list = function(friends){
for(var i in friends){
console.log(friends[i]);
};
};


#4

you should log the bill and steve properties, not the values of these properties


#5

I'm sorry I don't understand could u give me an example


#6

i contains the properties of friends thanks to the for in loop

so friends[i] will give you the value of the properties


#8

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