Stuck on this exercise since forever


#1



https://www.codecademy.com/en/courses/objects-ii/5/1#


It looks like you didn't print Hello!


Replace this line with your code.


#2

Please paste in your code so we can help you


#3

if(typeof languages.property === "string") {
    for(x in languages) {
        console.log(languages[x]);
    }
}
else {
    console.log("I can't say Hello");
}

#4

Your if/else statement needs to be in your for loop..
also missing var in for loop


#5

for(var x in languages) {
if(typeof languages.property === "string") {
console.log(languages[x]);
}
else {
console.log("I can't say Hello");
}
}

this doesn't work for some reason


#6

Your for loop will try to print all the keys in language object. However, we only interested in "string" not number. So to filter the number(in this case 4), we can write like this:

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

for (var key in languages) [think it this way: for item in languages]
{
if(typeof languages[key] === "string") [here we are declaring what type of key we are interested in]
{
console.log(languages[key]);

}
};


#7

Wow! Thank you so much! Great help in a very short time, awesome service :slight_smile: