Pig Latin algorithm last test not passing 'Should handle words without vowels.'

Hello guys, I have to admit that I am struggling with this algo test. In my opinion I am doing everything asked : every tests pass when we talk about changing the output of the str however I do have one test missing : “Should handle words without vowels.” and I do not understand what I am suppose to do to pass this test ?

Your code so far

function translatePigLatin(str) {
  let regex = /[aeiouy]/gi;

  if(str.match(regex) !== null){
    console.log('str.match(regex)', str.match(regex))
    let startBit = str.slice( 0,str.indexOf(str.match(regex)[0]) );
   if( str[0].match(regex) ){
      return str + 'way';
   } else {
    return str.slice(startBit.length) + `${startBit}ay`;
  } else if (str.match(regex) === null){
    return str + 'ay';


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36.

Link to the challenge:

“y” is not a vowel.

1 Like

You rocks :sob: I am in love with you ! you can’t imagine how many time I tried to redo my code, erase the lines optimisation to get to that :’( thank you so much
My bad for y ( ’ y ’ is a french vowel, that is why I was convinced it was too in english )

I’m glad I could help. When we’re little we are told that all words must have a vowel in them (which isn’t true), so then they thell us that the vowels are “a, e, i, o, u, and sometimes y” (which also isn’t true).

1 Like

Why would you say that?

Because “y” is not actually a vowel.

im so confused what do u mean by “y” is not a vowel?i can’t pass the test

In this challenge, y is not a vowel - phonetically it depends, but in this challenge it is not a vowel

Right… but does it correlates to “should handle words without vowels”? which part of my code should i change to fix ? i dont really get it

function translatePigLatin(str) {
    if (/^[aeiou]/i.test(str)){
    return str + "way";
  } else {
    return str.replace(/(\b[^aeiou]+)(\w.*$)/, "$2$1ay");



What does the function call you have added with nxnnx print to the console? It should print nxnnxay

yeah it prints that what about it?