Thanks for the help and guidance from all respondents, each was beneficial in helping me to understand this problem. I selected the following from @Commercial Suicide as my answer as the code was succinct and enabled me a way to iterate through them. I can now continue to access my planets and their various properties.
In Regards to duplicate: I didn't see the answer on the other page as a duplicate right away. many of the top answers were about getting foo or fizz properties and not the key. I see now buried further down in those answers someone did provide the answer "ECMAscript edition 5 also offers you the neat methods Object.keys()" Javascript get object key name
Cheers!
var planets = {
"Earth": {type: "Terrestrial ", location: "Milky Way"},
"Venus": {type: "Terrestrial", location: "Milky Way"}
};
//expanded for loop //
for(var key in planets) {
console.log("PLANET: " + key + " TYPE: " + planets.Earth.type + "LOCATION: " + planets.Earth.location);
}
UPDATE!! Here is a fiddle that shows the above as well as getting values from the inner object.
var moviesNested = {
Morag: {
Movie: 'Guardians..Galaxy ',
Hero: "Star Lord"
},
Tatooine: {
Movie: 'Star Wars',
Hero: "Skywalker"
}
};
function showMovieData(movieSet) {
for (var property in movieSet) {
//outer property ------------------------------------
console.log(property);
//inner as keys ---------------------------------
for (var key in movieSet[property])
console.log(key); //hero & movie
console.log(movieSet[property].Movie);
console.log(movieSet[property].Hero);
var fullString = "<p>" + property + " <br /> " +
movieSet[property].Movie + "<br /> " +
movieSet[property].Hero;
document.getElementById("outJS").innerHTML += fullString;
//document.getElementById("content").innerHTML += "Loop: " + i + "<br>";
}
}
showMovieData(moviesNested);
https://jsfiddle.net/carvingpixel/86rfvp8d/
Object.keys(planets)[0]??