Cant print only strings


#1

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

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

I think my code is fine . But it prints all the objects of languages.
Please help me


#2
for (var obj in languages)
{
   if( typeof obj === "string" )

first of all obj might be not a the best name as it implies that you have objects inside but what you really got there are keys or object properties. And as they are keys, they are by default strings. What you want to check is whether the corresponding value is string or not e.g. by: languages[obj]