So basically I want o loop through an error (what i already did) and print the other key
var planet = "sun";
var planets = [{
type: "sun",
desc: "sun"
}, {
type: "moon",
desc: "moon"
}];
var pln = planets.length;
for (var i = 0; i < pln; i++) {
console.log(planets[i]);
}
How can i I find out if the var planet is in the array planets and print out the description from that key if so?
typeof"sun", and print out the other object'stype("moon")?sunnor themoonare planets