Hello!
I cant understand why it doesn’t pass task “Should handle words without vowels.”
Thanks.
function translatePigLatin(str) {
let regex = /[eyuioa]/gi;
if (str[0].match(regex)) {
return str + 'way';
}
else if (str.match(regex) === null) {
return str + 'ay';
}
else {
do {
str = str.slice(1) + str[0];
}
while (str[0].match(regex) === null);
}
return str + 'ay';
}
console.log(translatePigLatin("cgnsgngnt"));
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin