Ok, first you made an object called
nyc. It has some properties and they've got some values. Regular behavior here.
Then you make
for loop (or foreach, because you loop through each property inside
So, what you get as
[fullName, mayor, population, boroughs]. I've put them to array because they are multiple, but you only get one at a time. So in first looping you have
console.log(), and try to print
nyc[property]. Property is now
fullName, and since
fullName = "New York City" in your
nyc object, it's printed. Second looping you have
mayor. When you're printing it, it will again check if it exist. Since it does exit, it prints
Bill de Blasio.
This will continue for as many properties you have on that object.
console.log(property)will just give you property name. Since you stated in your original post that you don't understand the code, but passed the lesson, I hope I managed to help you a bit.