Looks For-In To Me


#1

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

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

O/P
english:Hello!
french:Bonjour!
spanish:Hola!

But it showing
Oops, try again. It looks like you didn't print Hello!


#2

What course and exercise are you on? :slight_smile:


#3

javascript module 8 27th exersice


#4

You need to close the typeof method rght after your for loop variable [x],

should be,

if (typeof(languages[x]) === "string") {

and you are to console.log only the values no additional content,

console.log(languages[x])