6. List 'em all! Total confusion:


#1

Very stumped... Can someone tell my why my output is

bill
steve
["Two Street Way","Orlando","FL"]

rather than just bill and steve? Many thanks

var friends = {}
friends.bill = {}
friends.bill.firstName = "Bill";
friends.bill.lastName = "Horatio";
friends.bill.number = "514-555-5550";
friends.bill.address = ["One Lane Lane", "New York", "NY"];
friends.steve = {}
friends.steve.firstName = "Steve";
friends.steve.lastName = "Horatio";
friends.steve.number = "514-555-5551";
friends.steve.address = ["Two Street Way", "Orlando", "FL"];
var list = function (friends) {
for (i in friends) {
console.log(i);
};
};


#2

This is the last assignment made in the program so is still present in the buffer, which gets dumped to the console at the end of the program run. It can be ignored.

Instead of using dot notation to build the objects, it is much simpler to use literal:

var friends = {
    bill: {
        firstName: 'Bill',
        lastName: 'Gates',
        // and so on...
    },
    steve: {

    }
};

list(friends);
bill
steve

The gotcha here is that now the entire friends object is in the buffer, so displays. The trick here is to have the program do something after list(), such as log an expression.

console.log('Bye!');