Tell us what’s happening:
Everything is going to pass except: Should handle words where the first vowel comes in the end of the word.
But when I pass eight. I get eightway. The same with algorithm.
Your code so far
function translatePigLatin(str) {
let split = str.split("");
let vocals = ["a","e","i","o","u"];
let i = 0;
while (split.indexOf(vocals[i]) < 0){
i++
}
let rest = str.substring(0,i+1);
let leftovers = str.substring(i+1);
for (let j = 0; j < split.length; j++){
if (split.indexOf(vocals[j]) === 0){
return str + "way";
}
}
return leftovers + rest + "ay";
}
translatePigLatin("glove");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:62.0) Gecko/20100101 Firefox/62.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin