List 'em all! //Help please!


Hello! I keep receiving an error message that states "Did you create a function called list?"

I'm fairly certain I have. I believe there may be something wrong with my for/in syntax. Can someone help me?

friends = new Object();

friends.bill = new Object();
    friends.bill.firstName = "Bill"
    friends.bill.lastName = "Gates"
    friends.bill.number = "(555) 555-5555"
    friends.bill.address = ['1 Tech Way', 'Ozark', 'AL', '36360']
friends.steve = new Object();
    friends.steve.firstName = "Steve"
    friends.steve.lastName = "Jobs"
    friends.steve.number = "(555) 555-5555"
    friends.steve.address = ['1 Tech Way', 'Ozark', 'AL', '36360']
var list = function (friends) {
    for (var key in friends) {


Why build a loop, and the manually log bill and steve to the console? Use the loop to log the right data


Okay. So perhaps I should log the object friends then? I've tried that and I'm still not executing the code correctly. Can you provide some more insight?


I've got it! I must log key. It makes sense now.


good, that you made it work :slight_smile: And that it makes sense, more important


Well, actually. I'm still not sure I understand. I thought the whole point was to log each contact's information to the console. All that was logged was

["1 Tech Way","Ozark","AL","36360"]


this line is just logged by console behavior, it always logs the last value. So your understanding is correct


Yes, I understand now. I did not realize there was more to the code. I'm working on the next lesson now. Thank you!


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