9.Getting IN-timate, someone explain why it works please


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

for (var park in nyc) {

#Hello, I have gone through this exercise pretty easily, but I still don't understand why the code works.
#There is no variable park in the object nyc, so why does it print every property when I call park?

#Here is a link of the exercise:


#If someone can, please explain it to me. Thanks in advance.


the for in loop will in order/sequence assign property (fullName, mayor etc) to the loop iterator (park)

so park gets defined in the loop, the for in loop does most of the work for you


Thanks. So it works like the i variable in the previous for exercises, I guess.


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