List 'em all! Help


#1



When I try this I get an error message that says my list function isn't printing the right output. What am I doing wrong?


var friends = new Object();
friends.steve = {
    firstName: "Steve",
    lastName: "Johnson",
    number: 123-456-789,
    address: ['123 Steve Road', 'Monroe', 'La', '71203']
};
friends.billy = {
    firstName: "Billy",
    lastName: "Joe",
    number: 987-654-321,
    address: ['321 Billy Road', 'Monroe', 'La', '71203']
};
friends.john = {
    firstName: 'John',
    lastName: 'Daniel',
    number: 123-654-789,
    address: ['132 John Road', 'Monroe', 'La', '71203']
};
var list = function(friends) {
    for (var firstName in friends) {
        console.log(friends[firstName]);
    }; 
};
list();


#2

    for (var firstName in friends) {

what's is friends?
you are using parameter named friends. so inside function friends is now nothing.
either you should pass an arguments or remove parameter


#3

Do you mind explaining it a little better? I don't exactly get it. Thanks xD


#4

Basically your problem is in your console.log statement. You are console.logging both your argument and your parameter when you just need to console.log your parameter which is firstName. just like in the key example you are given in your lesson, you want to console.log that key to the screen because it will hold all the info. It is the "key" to the lesson hahahahaha....hahah...haha....ha......cough awkward silence so ya you get the picture?


#5

Ha ha ha. (Walks away) Yeah i get it now. Thanks. I understand what you mean


#6

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