Prints out one key, but not the others


#1



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


i don't get an actual error message, besides
"Oops, try again. It looks like your list function isn't printing the right output"


var friends = new Object();

friends.matthew = {};
friends.charles = {};
friends.callan = {};
friends.bill = {};
friends.steve = {};

var friends = {
    matthew: {
        firstName: "Matthew",
        lastName: "Holzer",
        number: "(999) 999-9999",
        address: ['Kingdom Hearts', 'Mickey Mouse', 'GA', '20423']
    }
};
var friends = {
    charles: {
        firstName: "Charles",
        lastName: "Crowner", 
        number: "(888) 888-8888",
        address: ['Battlefield 3', 'Assassins Creed', 'GA', '24902']
    }
};
var friends = {
    callan: {
        firstName: "Callan",
        lastName: "Lattimer",
        number: "(770) 777-7777",
        address: ['2015 drive', 'Yearbook', 'GA', '39092']
    }
};
var friends = {
    bill:  {
        firstName: "Bill",
        lastName: "Gates",
        number: "(206) 555-5555",
        address: ['one Microsoft Way','Redmond','WA','98052']
    }
};
var friends = {
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "(206) 444-4444",
        address: ['MacPro Drive', 'Los Angeles','CA','41099']
    }
};

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

assistance would be appreciated, xP


#2

if you want the list function to print all, you will need to call it:

list();

functions only execute when called


#3

so i added

list(); to the bottom, but that doesn't seem to have changed it, i'm still only getting one entry


#4

this line:

console.log(friends);

why friends? It should be key, since key will hold each of your friends in turn (thanks to the for in loop)

Also, your function has a parameter, so when you call it you need to pass in an argument (if i where to take i guess, i would say friends)


#5

ok, so changing console.log(friends) to console.log(key) worked, but it only listed one entry, the very bottom entry,
it allowed me to move to the next exercise, but i don't think it did what it was supposed to


#6

already covered that as well:

i was sloppy, you got me there, i made you use a function call without argument:

list(/* missing argument */);

Reworked entire script, to closer match the given examples, now "unexpected token '}' "