(ERROR) 6. List'em all!


#1



https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/6?curriculum_id=506324b3a7dffd00020bf661#

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


var friends = {
   bill:{
       firstName:"Bill",
       lastName:"Gates",
       number:"202-555-0121",
       address:["One Microsoft Way","Redmond","WA","98052"]
       },
   steve:{
       firstName:"Steve",
       lastName:"Jobs",
       number:"202-555-0188",
       address:["1 Infinite Loop","Cupertino","CA","95014"]
       }
}

var list = function(friendsNo){
    for (p=0;p<friendsNo.length;p++){
     return friendsNo[p];
    }
}

var totalFriends = list(friends);
console.log(totalFriends);


#2

I noticed that I made an error in the for loop section: I forgot to add "var" before my variable p for the loop,but still it doesnt work.


#3

why are you not using a for in loop? You can't access objects by index just like you do with arrays.

Also, if a return keyword is reached a function ends (even if it is in the middle of a loop)