Pig latin algo solution [solved]

function translatePigLatin(str) {
  
  let loop= str.split(/(?=[aeiou])/);
    return /^[aeiou]/.test(str)==true?str.concat("way"):str.slice(loop[0].length).concat(loop[0]+"ay");
 }
translatePigLatin("Consonant");

Showing a solution in public won’t help any campers. Go head and blur your solution in the text editor.