Keeps telling me I need to create a function 6/8


#1

var friends = {
bill: {
firstName: "Bill",
lastName: "Gates",
number: "(206) 555-5555",
address: [ "One Microsoft Way", "Redmont", "WA", "585849"]
}
};
var list = function(friends) {
for(firstName in bill) {
console.log("Who are they.");
var myString = "Woop";
consol.log(myString);
}
};


#2

Step one: Create a function list that takes a single parameter. This is correct

var list = function (friends) {
  //body
};

Step two: In the body of the function, write a for/in loop.

var list = function (friends) {
    for (var key in object) {
        //output
    }
};

"key" Can be anything you want it to be, i usually use a single form of the object. The "object" is a collection of many things, in this example object is "friends".

Step three: In the loop, use console.log to print out the key. (For example, if you only have bill and steve as entries, list should just print out "bill" and "steve".)

var list = function (friends) {
    for (var key in object) {
        console.log(key); //this prints out the key
    }
};

#3

I am having a similar problem...

I used the function exactly as you had it...

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

But it keeps on telling me "Oops... did you create a function called list?"

Yes I did! :frowning: Someone please help ... what's wrong with this?

My answer:

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

var friends = {
    bill: { firstName: "Bill", 
            lastName: "a",
            number: 1,
            address: ["1 Meadow", "Burl", "ON", "12345"]
    },
    steve: {firstName: "Steve", 
            lastName: "b", 
            number:2,
            address: ["2 Meadow", "Miss", "ON", "23456"]
    },
    frank: {firstName: "Frank",
            lastName: "c",
            number:3,
            address: ["3 Gozcu", "Ist", "TR", "34567"]
    },
    james: {firstName: "James", 
            lastName: "d",
            number:4,
            address: ["4 Elmd", "Ste", "MB", "45678"]
    }
}

#4

I posted the for loop as an example, you need to change the variables inside the parentheses.


#5

The "object" in the for loop should actually be "friends" in this case. The object should match the variable that you pass into the function. I had this same issue.