27/30 See this compiler don't even know the difference between a String and a number


#1

Can anyone make this baby understand the difference in between the string and the number. It treats "notAtLanguage" which is a number datatype as a string...


#2

the code:

if(typeof prop === "string")

returns false

when running your for loop for every key in languages the loop checks whether the key (properties) inside languages is false or not. I do not know how to see what state the keys are (true or false) but apparently they all must be false since your for loop actually prints them.

To check whether a value of a key inside of an object is a string you can use this code:

if (typeof (languages[prop]) === "string")

here, in the parentheses, the language object is being accessed at the position your for loop is at. To link to the position your prop variable is at (in other words the position your loop is at) is to put prop in brackets as shown above.


#3

try this instead
for (i in languages){
if (typeof languages[i] === "string"){
console.log(languages[i]);
}
}


#4

that's true buddy..nice work


#5

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

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