6. List 'em all!


#1

Oops, try again. Did you create a function called list?

(Im very confonfused about the last part (please dont laugh on ow wrong I am xD)


var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: 020202,
        address: ["One Microsoft Way','Redmond','WA','98052"],
    },
    steve: {
        firstName: 'Steve',
        lastName: 'Jobs',
        number: 010101,
        address: ["Two Apple Ways','SanFran','CA','25089"],
        }
};
var list = function(friends){ 
for (var key in object){ 
console.log(list)
}
};


#2

You were asked to loop through the friends object,

for (var key in friends) {

Your for loop,

is not looping over anything, because there is no iterable called object :slight_smile:


#3

ops sorry for the late reply, but thank you, i notised the other mistake i made too, so its all solved now, thanks agan


#4

I'm confused on this lesson because i dont understand how to use a for/in loop. I don't remember codecademy teaching it.

var friends = {
bill: {
firstName: "Bill",
lastName: "Hoen",
number: "(555)555-5555",
address: ["Hauling Dr.", "IA city", "8979879"]
},
steve: {
firstName: "Steve",
lastName: "Jingle",
number: "(777)777-7777",
address: ["Hauling Dr.", "IA city", "8979879"]
},
george: {
firstName: "George",
lastName: "Greene",
number: "(888)888-8888",
address: ["Hauling Dr.", "IA city", "8979879"]
}
}
var list = function () {
for ( ) {
console.log ( )
}
I don't know what to put in the for function and the console.log
Here are the directions:
Create a function list that takes a single parameter.
In the body of the function, write a for/in loop.
In the loop, use console.log to print out the key. (For example, if you only have bill and steve as entries, list should just print out "bill" and "steve".)


#5

For the function you put your variable that you used (Example: var list = function(friends) { }). Then the for loop should contain (for (var key in friends) { }). I had this same problem but found out.


#6

also I am having issues with this exercise. My code is:
var friends = new Object();

friends.bill = new Object();
friends.steve = new Object();

friends.bill.firstName = "Bill";
friends.bill.lastName = "Gates";
friends.bill.number = "(720) 333 2211";
friends.bill.address = ['Microsoft Road','Redmond','WA','98765'];

friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "(123) 456 7890";
friends.steve.address = ['Apple Street','San Diego','CA','12345'];

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


#7

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