List ALL the Properties!


#1


https://www.codecademy.com/courses/objects-ii/1/5?curriculum_id=506324b3a7dffd00020bf661#


Hello. I dont get any error, but just want something in this exercise explained to me: How does JavaScript know that "x" refers to the properties values? Haven't declared " var x" anywhere?


var nyc = {
    fullName: "New York City",
    mayor: "Bill de Blasio",
    population: 8000000,
    boroughs: 5
};

// write a for-in loop to print the value of nyc's properties
for(var x in nyc) {
    console.log(nyc[x]);  
}


#2

When you say for var x in nyc It is as if you are referring to the property values in the loop through the instant variable x.


#3

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