Tell us what’s happening:
Hello guys, my code for this exercise mostly works (despite being a bit hard to read) but it isn’t passing the last test regarding words without vowels. I ran it in repl.it and it came out with an output of ‘cnpltay’. Is there anything I’m doing incorrectly? Thank!
Your code so far
function translatePigLatin(str) {
if (str.match(/[aeiouy*]/)=='') return str + "ay";
if (str.match(/^[aeiouy]/)) str += "way";
else str = str + str.match(/^\w+?(?=[aeiouy])/) + "ay";
while (str.match(/^[aeiouy]/)==null) {
str = str.split("").splice(1).join("");
}
return str;
}
translatePigLatin("cmnplt");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin/