Pig Latin help needed

Tell us what’s happening:
Can someone guide me whats the problem in my code ? I have checked my code with different inputs at developer.mozzila.org with console.log in replace of return and its working fine.
Your code so far

   function translatePigLatin(str) {
  var newName = ""
var check = ["a","e","i","o","u"]
for(let i = 0; i <str.length;i++)
 { 
  if(check.includes(str[i]) == true)
  {
    
    newName = str.slice(i)
    let j = i

    i = str.length - 1
    if (newName.length == str.length)
    {
      newName = newName + "way"
}
      else{
      
newName = newName + str.slice(0,j) +"ay"

    }
  }
    else {
      newName = ""
    }
  }
  
  
   
 
    
return newName
    
  }
translatePigLatin("rhythm");

Thanks for your help , last challenge in this current challenge is to accept word with no vowels. My code works fine though. Why it is not accepting?

code edited, can you please check it now.

Can you check if there is an error with the challenge ?

What should it return if the word rhythm is passed, though it is not clear in instructions.

Thanks for your help. Done with the challenge. Was confused in consonant cluster thanks though.