6. List'em all! Please help with my problems!


#1


I've already passed this exercise but the result I got seems not quite right.
THIS IS MY RESULT:
bill
steve
["ngf","erg","2545"]

I still printed out the address value but this exercise required just the names.
I was wondering why it turned out like this.
Could anyone help me with this problem? Thank you!!!


var friends=new Object();
friends.bill= new Object();
friends.steve=new Object();
friends.bill.firstName="Bill";
friends.bill.lastName="Gates";
friends.bill.number="222-555666";
friends.bill.address=['abs','ggg','5555'];
friends.steve.firstName="Steve";
friends.steve.lastName="Jobs";
friends.steve.number="555-666999";
friends.steve.address=['ngf','erg','2545'];
var list=function(friends){
 for(var person in friends){
    console.log(person) 
 };  
};


#2

I don't understand what is your problem.
If call list(friends); result is:

bill
steve

If you change function list() like this:

var list=function(friends){
   for(var person in friends){
      console.log(friends[person]);
};  

list(friends.bill); // 
list(friends);

Results:

Bill
Gates
222-555666
["abs", "ggg", "5555"]

and:

{ firstName: "Bill", lastName: "Gates", number: "222-555666", address: ["abs", "ggg", "5555"] }
{ firstName: "Steve", lastName: "Jobs", number: "555-666999", address: ["ngf", "erg", "2545"] }

Is it what are you looking for?


#3

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