Hello. My code isn’t passing the last two tests.
**Should handle words where the first vowel comes in the end of the word.
**Should handle words without vowels.
Could I get some help with it? Thanks in advance!
function translatePigLatin(str) {
let regexV = /[aeiouAEIOU]/;
let regexC = /[bcdfghjklmnpqrstvwxyz]/;
console.log(str.charAt(0));
if (regexV.test(str.charAt(0))) {
str = str + "way";
} else if (regexC.test(str.charAt(0)) && regexC.test(str.charAt(1))) {
return str.slice(2) + str.slice(0,2) + "ay";
} else {
return str.slice(1) + str.slice(0,1) + "ay";
}
return str;
}
translatePigLatin("consonant");