isNaN instead of typeof? Why does the code still print out numbers?


#1

https://www.codecademy.com/courses/objects-ii/5/1?curriculum_id=506324b3a7dffd00020bf661#

Instead of using the typeof operator, I want to try isNaN so the code skips the number and only prints out the languages.
But the code still churns out 4, do you know why?


Replace this line with your code. 

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

// print hello in the 3 different languages
for ( var x in languages) {
    if(isNaN(x)) {
        console.log(languages[x]);
    };
};


#2

what is the value of x?

shouldn't it be

if(isNaN(languages[x]))


#3

yes! thank you very much


#4

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