Need help!


#1



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


I don't understand the last part of this lesson. I made a function called list, but the for loop in it makes no sense. The error message says: "Oops, try again. Did you create a function called list?"


var friends = new Object();
friends.bill = {
    firstName: "Bill",
    lastName: "Gates",
    number: "512-545-8002",
    address: ["2109","Reston Cove","Round Rock, TX"]
},
friends.steve = {
    firstName: "Steve",
    lastName: "Jobs",
    number: "512-999-5124",
    address: ["1492","magical pathway","HELL!"]
}
var list = function (friends)   {
    for (var key in object) {
        console.log(friends);
    };
};


#2

HI your for loop ..

for (var key in object) {
    console.log(friends);
};

you want to loop through friends so it should be

for (var key in friends)

then you should print key instead of friends inside the for loop


#3

Will you kindly check on my same situation?


#4

Hi You should post your code or create a new topic with tour code And The error You get


#5

A for...in loop only iterates over enumerable properties. Objects created from built–in constructors like Array and Object have inherited non–enumerable properties from Object.prototype and String.prototype, such as String's indexOf() method or Object's toString() method. The loop will iterate over all enumerable properties of the object itself and those the object inherits from its constructor's prototype (properties closer to the object in the prototype chain override prototypes' properties).
Not (var key in object).
Its for(var key in friends)