6. List them all


#1

Hi All,
Could someone help me please, I am really lost!!!

The console log dislays "[function:list]"
any ideas??

var friends = {
steve: {
firstName:"Steve",
lastName: "johnson",
number: "090909090",
address: ['One Microsoft Way','Redmond','WA','98052']

   },

bill: {
firstName:"Bill",
lastName: "johns",
number: "098765432",
address: ['two Microsoft Way','Redmond','WA','98052']

   
   }

};

var list=function(friends) {

for(var firstName in friends) {
console.log(list);
}

}

Replace this line with your code.

`


#2

I think your problem obviously is your for(var firstName in friends) You need to use var in statement with key instead of firstName and then console.log that key.


#3

Brilliant Thanks for your help!


#4

No problem man! :smiley: glad to help especially on ones I had problems with too


#5

Try this code:

var friends = {
bill: {
Firstname: 'Bill',
lastName: 'Gates',
number: '(208) 555 5555',
address: ['One Microsoft Way', 'Redmond', 'WA', '98052']
},
steve: {
firstName: 'Steve',
lastName: 'Jobs',
number: '(210) 777 7777',
address: ['One Apple Way', 'Santa Ana', 'CA', '79590' ]
}
};

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


#6

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