27. Looks For-In to me - URGENT


#1


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


Hi everyone, please see my code in below. Instead of saying an if they are "string", I was trying to say if they are NOT NUMBER. However, I don't know why the system is not allowing me to pass?

Can someone help me?


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

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


#2

Here is where the error is coming from instead of,

Just type in,

if (typeof x === "string")

#3

Is not number.

if (typeof languages[i] !== "number") {

}

#4

I think you meant to address :sweat_smile: @jim_prince


#5

Thank you! It works and I understand it now.


#6

If you guys are wondering why he had the error in the first place, it's because the exercise's instructions said explicitly to "check if the type was a "string""


#7

This is my answer:
for(var x in languages){
var x=languages[x]
if(typeof x=="string"){
console.log(x);
}
}


#8

for(var x in languages){
var x=languages[x]
if(typeof x=="string"){
console.log(x);
}
}


#9


#10

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