Tell us what’s happening:
I just have a question with my or statements in the first if statement. The only test case that passed when I only had the first if statement was ‘algorithm’. this led me to believe that my or statements aren’t working so I hardcoded an else if to handle the case with ‘eight’ and that passed. I could do a long list of else ifs for every vowel maybe even ‘y’ but that seems pretty redundant. is there a way I can get the function to check see if str starts with a vowel?
Your code so far
function translatePigLatin(str) {
if (str.startsWith('a'||'e'||'i'||'u'||'o')){
return str + "way";
} else if (str.startsWith('e')) {
return str + "way";
}
}
translatePigLatin("consonant");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin