HELP! List 'em all! is not working!


#1


https://discuss.codecademy.com/t/archive-of-qa-for-this-lesson/123 everyone else.>


List 'em all!


The error message says 'Opps, try again. Did you create a function called list?' Can anyone help? and by the way, I am only 12 so please no complicated words because I have seen some on other discussions. Thanks


Replace this line with your code. 
var friends = {
    bill: {
        firstName: 'Bill',
        lastName: 'Gates',
        number: '01243567890',
        address: ['ABC Close, London, BN9 7PN']
    }
}
var friends = {
    steve: {
        firstName: 'Steve',
        lastName: 'Lank',
        number: '01234567890',
        address: ['DEF Close, London, BN9 7NP']
    }
};

var list = function (friends) {
    for (var bill in friends) {
        console.log(firstName);
    }
};


#2

You are looking for the first name here, so instead of var bill it should read var firstName...

var list = function(friends)
{
for (var firstName in friends) {
console.log(firstName)
}
}

In your for loop, you are printing the firstName using the console.log function but your not calling for it in your for loop.

Also, if your creating a new object called "friends", then you dont need to create it twice.

var friends = new Object();

friends.bill = new Object();
friends.steve = new Object();

I'm still learning myself, so there might be a better way to even improve on my code, but with my code, I created the object "Friends" once and then used dot notation to create 2 more objects for each friend.


#3

Thank you! I have been trying to find the error for like half an hour non stop! I think I was trying to print everything cause it is like midnight XD @erfwerm


#4

LOL! Its all good man. 2am knows all my secrets. The later it gets, the more I tend to overlook things like brackets and ; and such. Im glad i could help. Happy coding!


#5

Lol you 2 :smile: @erfwerm


#6

Thanks for the help. I happened to need this. Cheers!