Look for-in to Me


#1

Hey guys, I'm in intro to objects 2 Lesson 27 "Look for-in to Me", and I'm having a hard time figuring out how to print out the string properties. This is my code...

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

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

Any help would be greatly appreciated and an extra thank you if you can explain your process.


#2

A simple syntax error.
That second to last bracket, should be a closing bracket, not an opening bracket, because it's closing the else statement.

Though, without anything inside the else statement, there's really no point in having it there at all. I would just delete the

else {
{

altogether.


#3

You have an opening brace { at the end instead of a closing one }.


#4

In line 10, inside the if parameters you must adress the variable as typeof languages[x] instead of just typeof x.
Had the same problems in this exercise.


#5

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

Use typeof as shown above.


#6

in this way it works too, it's no necessary typeof method

for(var english in languages){

if(languages[english] != 4){
    console.log(languages[english]);
        }


};

i know it's a trap xD