I am trying to learn more about loops and am attempting to access object properties in JSON format.
My JS is:
var movies = {
"Black Panther" : {
"title" : "Black Panther",
"theatricalrelease" : "2/16/2018"
},
"Infinity War" : {
"title" : "Avengers: Infinity War",
"theatricalrelease" : "5/4/2018"
},
"Captain Marvel" : {
"title" : "Captain Marvel",
"theatricalrelease" : "TBA"
}
}
console.log(movies); //logs correctly
console.log(movies.length); //logs undefined
for (var i = 0; i < movies.length; i++) {
console.log(movies[i]); // doesn't log anything
}
How can I access object properties like title
and theatricalrelease
?