For / in loop


#1

I have no idea at all what a for / in loop is. Can someone please explain?
Here's my code:

     for (var key in object)   
        console.log(object[key])
friends = {
 bill: {firstName: 'Bill', lastName: 'Dribble', number: '111-323-6784', address: ['seven hot road','wipple','WA','87993']},   
 steve: {firstName: 'Steve', lastName: 'Arcensaw', number: '543-766-1532', address: ['rest ave','yufy','TX','21555']},   
  billy: {firstname: "Billy",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ['One Microsoft Way','Redmond','WA','98052']
         }, 
  elias: {firstName: 'Elias', lastName: 'Tristan', number: '124-578-9012', address: ['Florence Ave', 'Pittsburgh','PA','15202']}
    };
    list(friends)   
    }

The error I get is: Oops, try again. Did you create a function called list?


#2

Post muli-line code with three backticks (`) on a line above and a line beneath your code. They should be on separate lines from anything else.


#3

Also a for / in loop should look like this,

for (var key in object) {
    //do something
}

And your function should end right after the for / in loop.


#4

Thanks dantemp that really helped!!


#5

No problem, 'swhat I'm here for.