Tell us what’s happening:
I am getting the right output for all the test cases but I dont know why the test isnt getting through for words starting with vowels or words with no vowels
Your code so far
function translatePigLatin(str) {
let r=/(^[^aeiou]+)([a-z]+)/i;
let e=/(^[aeiou])|(^[^aeiou]+$)/i;
if(e.test(str)){
console.log(str.replace(/(.*)$/,"$1way"))
return str.replace(/.*$/,"way");
}
else{
return str.replace(r,"$2$1ay");
}
}
translatePigLatin("eight");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36
.
Challenge: Pig Latin
Link to the challenge: