Need a help to complete Pig Latin challenge

I need a help here.I can’t complete this test .I tried the below code it has met all the constrains except last one .How to handle the word without vowels.

code:

function translatePigLatin(str) {


 var regex = /[aeiou]/gi;
  var pigLatin ="";
  var letters =str.split("");
   if(regex.test(letters[0])){
      return letters.join("") + "way";
   }
   while(true){
  if(!regex.test(letters[0])){
      letters.push(letters.splice(0,1));
  }
  else{
    break;
  }
   }
 str =letters.join("")+"ay";
   return str;
   }
   

translatePigLatin("consonant");

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/pig-latin

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

In word without vowel just concatinate “ay” in the end of str and return

this is my code btw

function translatePigLatin(str) {
  let check=/[aeiou]/;
  let newstr="";
  let index = str.indexOf(str.match(check));
if(index!=-1)
{
  if(index==0)
  {
    return str.concat("way"); // vowel found at index 0
  }
  else return str.slice(index)+str.slice(0,index)+"ay"; //vowel found in between
}
 else return str.concat("ay"); //word without vowel
}
console.clear();
console.log(translatePigLatin("cnsnnt"));