Help with look for-in to me


#1

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

// print hello in the 3 different languages
for(var x in languages){
console.log(1);
}


#2

this is all I have :rage:


#3

I think you need to put "x" in place of "1". So...
for(var x in languages) {
console.log(x);
}


#4

Lot going on here..lol...so you created the "for" argument correctly up until the console.log.

You still need to include the "IF" statement. I don't really want to just GIVE you the answer, because half of learning is figuring it out, but I will say that you should have 3 lines of code:

for(var x in languages) {
if( STUFF GOES IN HERE ) {
console.log( STUFF GOES IN HERE );
};
};

If you truly still need more help, reply back and I'll post the rest of the code, but do your best to get it. Don't forget the Hint section has some good clues, as well!


#5

thank you for the help
:smile:


#6

I don't know what's wrong with the following 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.value == "string") {
console.out(x.value); }
}


#7

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

you have console.out, which needs to be console.log. then change the two x.value over to be language[x], which is calling each of the variables in language.

Hope that helps.


#8

Worked perfectly.
Thank you.