Intermediate Algorithm Scripting:Pig Latin Challenge

Hello, I am doing the Pig Latin challenge and it is giving me an error.
It says that it should handle words without vowels.
This is my code:

function translatePigLatin(str) {
  var patt = new RegExp("\[aeiou]+");
    return str+'way';
  }else if(!str.match(patt)) {
     var index=str.indexOf(str.match(patt));
     return str.substr(index)+str.substr(0, index)+"ay";

Currently, if you were to call your function with the word “rhythm”, it would return “may” instead of the correct value of “rhythmay”.

That is not the only test your are failing with this code. For “california”, “paragraphs”, and “glove”, your function returns undefined. Why? Because your if and else if conditions evaluate to false, so no return statement is executed. By default, functions will return undefined if not return statement is executed upon function completion.