Exercise 6 "List 'em all!" - Not printing the right output?


#1



According to the exercise, I just need to print out "bill" and "steve". However, the error message says I'm not printing the right output. What is the right output I'm looking for?


var friends = new Object();
friends.bill = {};
friends.steve = {};
friends.bill.firstName = "Bill";
friends.bill.lastName = "Waterson";
friends.bill.number = "123-456-7789";
friends.bill.address = ["Two Easy Street", "Boston", "MA", "02134"];

friends.steve.firstName = "Steve";
friends.steve.lastName = "Stevenson";
friends.steve.number = "987-654-3321";
friends.steve.address = ["Seven Hearts Lane", "Queens", "NY", "11245"];

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


#2

In this lesson, you should be logging the key instead of the key's first name. Your function should look like this:

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

Simple fix of expected output.


#3

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