[CLOSED] Intermediate Algorithm Scripting: Pig Latin.Handling words without vowels

It is not explained in the challenge how words without vowels should be handled, but looking at solutions I understand that words without vowels should be simply suffixed with “ay”. The code below passes every test except handling words without vowels, although seemingly it should do that as well.
I know there are many other solutions, but I need help finding out why this one isn’t working.
Sorry if the code is not readable, I tried to fit everything into one return statement.

function translatePigLatin(str) {

  return !(/[aeoiuy]+/i).test(str) ? str + "ay" : //if no vowels, add "ay".
   (/^[aeiouy]/i).test(str) ? str + "way" : //else if starts with a vowel add "way".
   str.replace(/^[^aeoiuy]+/i,"") +  //else move consonant(s) from the beginning to the end and add "ay"
   str.match(/^[^aeoiuy]+/i)[0] + "ay";

link to the challenge

“y” is not a vowel.

1 Like

yep, that solves it. Thanks