6/8 making list function


var friends= {};
firstName: "Bill",
lastName: "Gates",
number: "(555) 675-8967",
address: ['One circle lane, Mountainview,CA']

lastName: "Jobi",
number: "(567) 867-8999",
address: ['8 street, Concord,CA']

firstName: "Marnie",
lastName: "Jackson",
number: "(444)888-2222",
address: ['9 Bay Place, Vallejo, CA']

firstName: "Manuel",
number: "(555)888-6789",
address: ['5 koolaid street, east timor']

var list= function (obj){
for(var something in object){

so in this exercise, we've already written out all our contacts as objects, and now we want to
print out all of the info (all of the "strings") that we've entered for our contacts, right? and the way we do it is to make a list function, using a 'for/in' loop, to assign a 'key' word to each of our contacts, so that we can use the list function (with the for/in loop) to print out the info in the contacts, right?

I'm just trying to get the bigger picture right so that I can understand why we are doing this.

so when i run the code how it is, it prints out only the info in my last contact, but not for the first 3 contacts

next, what is wrong with how I'm writing my function? I'm thinking that:
1. my parameter doesn't make sense
2. there's something wrong with the key: whats the key supposed to be? the instructions said its just anything that stands in the place of something, like a parameter

the other thing is that this function is just talking about one object, so maybe thats why its just printing one object? do i need to refer to the other objects somehow?


The environment we are working in is directly tied to terminal command line, though we don't have access to it, except through the code we submit. When we submit, our code is given to the compiler via the command line interpreter. The natural response of the terminal (console) is to echo the last assignment if no logging is ordered at the conclusion of the program.

In this instance, evidenced by the OP, that last assignment (last command executed) is

friends.manuel = {
    firstName: "Manuel",
    number: "(555)888-6789",
    address: ['5 koolaid street, east timor']

therefore the response is,

{ firstName: "Manuel", lastName:"Macuco", number: "(555)888-6789", address: ['5 koolaid street, east timor'] }

This is completely expected once we understand the console and how a terminal responds to commands.