Please help me where is my mistake

Tell us what’s happening:

Your code so far


function translatePigLatin(str) {
  let firstel =[];
  let secondel;

  function check(el){
    let reg = /^[aeiouy]/;
    return reg.test(el);
  }

  if(check(str)){
    return str +='way';
  }else{
   firstel = str.split('');
   while(!check(firstel[0])){
    secondel = firstel.shift();
   firstel.push(secondel);
  }  
  }
  
  return firstel.join('') + 'ay';
}

console.log(translatePigLatin("glove"));

Your browser information:

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

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

In the English language, “y” is not a vowel. Also, what if the word has no vowels, like in the word “rhythm”? Your function gets stuck in an infinite loop based on the while loop condition.

Thank you very much …