6. List ‘em all - code works, but how?



My code does work correctly, but there is one aspect that I don't understand, I'll explain:

So I've made the friends object, and made two objects within that, with keys.

Then I write this piece of code:

var list = function (obj) {
for (var i in obj) {

and the names 'bill' and 'steve' get printed, as expected. But how come the function knows how to use the object 'friends'? I did not specify that. Can onyone explain me that?

Thank you

var friends = new Object();
    friends.bill = new Object();
    friends.steve = new Object();
    friends.bill.firstName = 'Bill';
    friends.bill.lastName = 'Gates';
    friends.bill.number = '0611833845';
    friends.bill.address = ['Microsoft Way 1','2455HH','Dordrecht'];
    friends.steve.firstName = 'Steve';
    friends.steve.lastName = 'Jobs';
    friends.steve.number = '0622222222';
    friends.steve.address = ['Straat 3','233HH','Dordrecht'];
var list = function (obj) {
    for (var i in obj) {


Hello @blogmaster83388,

Your code is deploying the names even though you haven't specified anything because that is just Codecademy checking the validity of your code.


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