Intermediate Algorithm Scripting: Pig Latin - Can't pass last two tests

I’m struggling to pass the last two tests for this challenge and I can’t figure out why. I’ve tested both of the last cases in chrome console and seem to not have any issues. I know my code isn’t very clean so I apologize beforehand. Here is my code:

 function translatePigLatin(str) {
   let testVowel = [];
   let testConsonant =[];
   let editArr = str.split("");
   testVowel = str.match(/[aeiou]/i);
   testConsonant = str.match(/[b-df-hj-np-tvxz]+/i);
   if (testVowel == null){
     return str;
   }
   if (testVowel != null && str.indexOf(testVowel[0]) == 0 ){
     return str + "way";
 }
   editArr.splice(editArr.indexOf(testConsonant[0][0]),testConsonant[0].length)
   editArr.push(testConsonant[0],'a','y');
   str = editArr.join("");
   return str;
 }

For a word like “schwartz”, your function should return “artzschway”, but instead returns “wartzschay”

For a word like “rhythm”, your function should return “rhythmay”, but instead returns “rhythm”

Did not realize my regex was incorrect and didn’t quite understand the challenge completely. Thank you for your help!