Exercise 6 "list 'em all!" not working


#1



Creates an error saying "did you create a function called list?". Don't know why it's going wrong, could it be that "list" is turning blue whenever I put it in?


var friends = {
 bill: {
     firstName: "Bill",
     lastName: "Gates",
     number: "(123) 456 789",
     address: ["1 main street", "Citytown", "WA", "1234"]
 },
 steve: {
     firstName: "Steve",
     lastName: "Jobs",
     number: "8008135",
     address: ["1 default drive", "Cityplace", "NSW", "123"]
 }
};
var list = function(friends){
    for (var friend in object) {
        console.log(friend)
    }
};


#2

this line:

for (var friend in object)

the object you should loop over is friends (your function parameter)


#3

That didn't seem to fix it? Am I doing anything else wrong?


#4

can you post an updated version of your code?


#5

yeah, here it is:

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(123) 456 789",
address: ["1 main street", "Citytown", "WA", "1234"]
},
steve: {
firstName: "Steve",
lastName: "Jobs",
number: "8008135",
address: ["1 default drive", "Cityplace", "NSW", "123"]
}
};
var list = function (friends){
for (var friends in object) {
console.log(friend)
}
};
sorry, probably not formatted too well


#6

this line:

for (var friend in object)

friend is what will the individual properties from inside the object.
object is the object you loop over, what is the object called in your case? (object requires changing, friend is fine)


#7

That fixed it, thanks!


#8