Help


#1

I tried accessing VALUE of property-key with this code:
var nyc = {
fullName: "New York City",
mayor: "Bill de Blasio",
population: 8000000,
boroughs: 5
};

for( var i in nyc) {
console.log(nyc.i)
}

Why didn't it work ??


#2

Because i is a dynamic variable, we cannot use it in dot notation. We must use subscript (bracket) notation to express the respective value associated:

console.log(nyc[i]);