6. List them all wont work


#1

I am so confused to why this wont work. My problem is with the for loop, could anyone help with this?

var friends = new Object();

friends.bill = {
    firstName:"Bill",
    lastName: "Gates",
    number: "(555) 2941",
    address: ["Microsoft"]
}

friends.steve = {
    firstName: "Steve",
    lastName: "Jobs",
    number: "0345 6060973",
    address: ["The Grave"]
} 


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

Any help would be much appreciated. Thanks


#2

Was having the same issue as you, this is what I was able to do to fix it
.
var list = function (friends) {
for (var key in friends) {
console.log(key);
}
}

Just tell the console to log key, instead of friends[key].


#3

Thanks! Much appreciated


#4

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