Tell us what’s happening:
Hey guys,
I am trying to solve the Pig Latin algorithm. For some reason the top version with == works as expected but when I use the second version with !== I get an unexpected output. Be sure to change the parameter passed to the function with a word that starts with a vowel to see the unexpected behavior.
Thanks!
Your code so far
function translatePigLatin(str) {
var str = str.split("")
if (str[0] == "a" || str[0] == "e" || str[0] == "i" || str[0] == "o" || str[0] == "u" ) {
return true
} else {
return false
}
}
translatePigLatin("glove");
function translatePigLatin(str) {
var str = str.split("")
if (str[0] !== "a" || str[0] !== "e" || str[0] !== "i" || str[0] !== "o" || str[0] !== "u" ) {
return true
} else {
return false
}
}
translatePigLatin("glove");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36
.