<풀이 코드>
const planet_kr = ["수성", "금성", "지구", "화성", "목성", "토성", "천왕성","해왕성"];
const planet_en = ["Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"];
const name = prompt();
for(var i in planet_kr){
if(name == planet_kr[i]){
console.log(planet_en[i]);
}
}
<답안> //key,value 방식
const planet = {
'수성' : 'Mercury',
'금성' : 'Venus',
'지구' : 'Earth',
'화성' : 'Mars',
'목성' : 'Jupiter',
'토성' : 'Saturn',
'천왕성' : 'Uranus',
'해왕성' : 'Neptune'
};
const name = prompt();
console.log(planet[name]);