Pig Latin algorithm problem

Pig Latin algorithm problem
0

#1

I wrote this code, it solved all except the word “glove” and I’m not sure why I need to make it return “oveglay” it starts with a consonant like the other words why I need to move the letter “L”? anyone can explain, please
function translatePigLatin(str) {

var vowel = [“a”, “e”, “i”, “o”, “u”];
var firstLetter = str.charAt(0);

if (vowel.indexOf(firstLetter) === -1) {
  
	var newStr = str.split("");
    var removed = newStr.splice(0, 1);
    str = newStr.join("") + removed + "ay";
  
} else {
	str = str + "way";
}

return str;
}

translatePigLatin(“glove”);


#2

Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an “ay”.

gl is consonant cluster


#3

in pig latin, all consonants are removed up until a vowel in encountered, not just the first letter, therefore glove should result to oveglay while ‘Cheers’ for example is ‘Eerschay’. hope that helps, If you want to have a look at my attempt I can post the snippet here, though it’s a bit messy cause I got lazy towards the end.


#4

Thanks @jenovs and @Lewis98 for your explanations.