Tell us what’s happening:
Else if statements not executing correctly. The first 3 ticks are correct, however on ‘algorithm’ and ‘eight’ it doesn’t seem to execute the else if statement to at the ‘way’ to the end of those strings. Could someone guide me on why this could be happening.
Thank you
Your code so far
function translatePigLatin(str) {
if (str.charAt(0) !== 'a' || 'e' || 'i' || 'o' || 'u') {
let strVowel = str.search(/[aeiou]/g);
let cutOf = str.substr(strVowel).concat(str.slice(0, strVowel)).concat("ay");
return cutOf;
} else if (str.charAt(0) == 'a' || 'e' || 'i' || 'o' || 'u') {
return str.concat("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/88.0.4324.150 Safari/537.36
.
Challenge: Pig Latin
Link to the challenge: