Pig Latin — Should handle words without vowels

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

“y” is not a vowel.

1 Like

Thank you very much!
‘y’ in the Russian alphabet is vowel so i thought, English ‘y’ is vowel too. :):grin:

It’s a pretty common confusion, especially because we have a multilingual community.