Hey!
I have gotten stuck on passing the last test, and I keep getting “should handle words without vovels” as the error message, even though it seems to be returning the right things…
Can someone please help me?
function translatePigLatin(str) {
let reg = /[aeiouy]/;
let reg2 = /[aeiouy]/gi;
let temp = “”;
let piglatin = “”;
let cut = 0;
let start = “”;
if(str[0].match(reg)){
piglatin = str+“way”;
}else if(str.match(reg2) === null){
piglatin= str+“ay”;
}else{
cut = str.indexOf(str.match(reg));
start = str.slice(0, cut);
temp = str.slice(cut, str.length);
temp+= start;
piglatin= temp + "ay";
}
return piglatin;
}
translatePigLatin(“hall”);
//hall returns allhay
//all returns allway
//ll returns llay