(Don't) List 'em all! - Javascript


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-3bmfN/0/6?curriculum_id=506324b3a7dffd00020bf661


Prints out what I expect. Error message: "Oops, try again. It looks like your list function isn't printing the right output."

var friends = {
    bill: {firstName: 'Bill', lastName: 'Gates', number: '1(800)-I-SO-RICH', address: ['One Microsoft Way', 'Redmond', 'WA', '98052']},
    steve: {firstName: 'Steve', lastName: 'Jobs', number: '1(800)-IPHONE-7', address: ['One Infinite Loop', 'Cupertino', 'CA', '95014']}
};
var list = function() {
   for(var name in friends) {console.log(friends[name])} 
};


#2

Figured it out.

var friends = {
    bill: {firstName: 'Bill', lastName: 'Gates', number: '1(800)-I-SO-RICH', address: ['One Microsoft Way', 'Redmond', 'WA', '98052']},
    steve: {firstName: 'Steve', lastName: 'Jobs', number: '1(800)-IPHONE-7', address: ['One Infinite Loop', 'Cupertino', 'CA', '95014']}
};
var list = function() {
   for(var key in friends) {console.log(key)} 
};

#3

here is somthing that might work, your function is wrong this is what it should be...

           var list = function(obj) {
           for(var prop in obj) {
           console.log(prop);
      }
   };

try this it might work


#4

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