Pig Latin challenge don't pass last test

Hello, I’ve trying to solve “Pig Latin” challenge (link below), but my code don’t pass the last test Should handle words without vowels..
Using to one of the given solutions (which passes all the tests) and comparing the output with the one I got from my solution I don’t spot any differences.

Can you help me understanding what I’m doing wrong?
Here’s my code:

function translatePigLatin(str) {
  let constr1 = /^([aeiou])([a-z]*)/gi;
  let constr2 = /^([cdfghjklmnpqrstuvxwz]*)([aeiou]*)([a-z]*)/gi;

  let mConst1 = constr1.exec(str);
  let mConst2 = constr2.exec(str);

    str = str.replace(constr1, '$1$2way');
  else if(mConst2)
    str = str.replace(constr2, '$2$3$1ay');

  return str;

let output = translatePigLatin("glv");
console.log(output); //output is: glvay

For more information I’m using this browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36.

Thank you.

If this should be all consonants you may need to recheck the alphabet - you are missing the b, the u is not a consonant, etc


And, in this particular challenge, the word that is tripping you up is rhythm – you don’t check for y, and in this context, y is not considered a vowel.

1 Like