Can't pass the "List 'em all" exercise


#1


What is wrong with my code? I have followed the instructions, but for some reasons it gives me a syntax
error, saying "Unexpected token var".


var friends = {
    bill: {
        firstName: "Bill",    
        lastName: "Node",
        number: "060 - 1234567",
        address: ["Redwood Square"]
    },
    steve: {
        firstName: "Steve",    
        lastName: "Johnson",
        number: "060 - 7654321",
        address: ["Vespucci Beach"]
        }
    var list = function (friend) {
    for (var friend in friends) {
        console.log(friend);
    }
}        
};


#2

the list function should be after you finished building your friends object


#3

You function uses global variable and not universal. Much more effective to make universal functions. Like this:

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

And yes, after object building.


#4

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