Pig Latin( Should handle words without vowels.)

Tell us what’s happening:
My code is not passing the last test when it is working perfectly in the browser console.
The last test says : Should handle words without vowels.

Your code so far


function translatePigLatin(str) { 
  let  result;
  if(/[^aeiou]+/.test(str) === true){
    result = str+"way";
  }
    if(str.match(/(^[^aeiou]+)/) !== null){
      let sub2 = str.replace(/(^[^aeiou]+)(\w+)/,"$1 $2");
      let arr = sub2.split(" ");
      result = `${arr[1]}${arr[0]}ay`
    }else{
      result = str+"way";
    }
 
  
  
  return result;
}
translatePigLatin("hhhjjjhhhjjj");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

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

Your code is not returning the correct result. It is moving the last letter to the beginning.

Oh! shhh silly mistake got the issue,
thanks for pointing it out.
HERE is my solution:
function translatePigLatin(str) {
let result;

function translatePigLatin(str) { 
let  result;
if(str.match(/[aeiou]+/)){
       if(str.match(/(^[^aeiou]+)/)){
         let sub2 = str.replace(/(^[^aeiou]+)(\w+)/,"$2$1ay");
         result = sub2
       }else{
         result = str+"way";
       }
     }else{
         result= str+"ay";
     }
return result;
}

translatePigLatin("consonant");