27/30 Looks For-In to Me


#1



I have no idea what I'm doing wrong! I have no idea how to crack and debug this code so that it prints all three "Hello" in languages.
My error is: "Oops, try again. It looks like you didn't print Hello!"


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

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


#2

Hi @sassyglo

Would you mind sharing a screenshot of the error with your code visible please?
Only I went through the code and I also plugged it in to that lesson, it passed the lesson happily as is :slight_smile:

Just curious if you haven't resolved this yet and you could get an image of the console as you work/submit maybe we will see something, failing that please try old faithful cache clean out for your browser, maybe anther browser or if you a have any other question please feel free to reply and someone will try to get back as soon as they can.

:slight_smile:


#3

I do not know if my decision is correct. However, but the code works.
for(var x in languages){
var myString = "string";
if(typeof languages[x] == myString) {
console.log(languages[x]);
}
}


#4

Earleir in the lesson we learnt the isNaN() function.

var languages = {
english: "Hello!",
french: "Bonjour!",
notALanguage: 4,
spanish: "Hola!"
};
// print hello in the 3 different languages
for(var key in languages){
if(isNaN(languages[key]))
{
console.log(languages[key]);
}
};


#5

your code worked just fine for me...pretty sure u just need to refresh browser or F12 and clear cache before


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.