How do I print only strings


#1

This is my code and its printing all four.

var languages = {
english: "Hello!",
french: "Bonjour!",
notALanguage: 4,
spanish: "Hola!"
};

// print hello in the 3 different languages
for(var property in languages){
if(typeof(property)==="string")
{
console.log(languages[property]);
}
}


#2

You don't check for typeof property === "string", but typeof languages[property] === "string".
property will give keys, and languages[property] values.


#3

Thankx it helped. Such silly mistake :Psweat_smile: