Tell us what’s happening:
for my understanding.
- if string begins with vowels(a,y,u,i,o,e) then add “way” at the end of the string.
- if string doesn’t being with vowels then remove first Char and add to end of the string + “ay”;
so my code is passing passing but the “glove”? it says supposed to return “oveglay”;
which I can’t understand.
Also how do we use regex to check for vowel? is it right place to use regex?
thanks in advance…
Your code so far
function translatePigLatin(str) {
var vowelCheck = str.charAt(0);
if(vowelCheck == "o" || vowelCheck == "y" || vowelCheck == "e" || vowelCheck == "a" || vowelCheck == "u"){
return str + "way";
}
else {
return str.slice(1) + vowelCheck + "ay";
}
}
translatePigLatin("glove");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/challenges/pig-latin