Pig latin challenge

Pig latin challenge
0.0 0

#1

function translatePigLatin(str) {
let pigLatin = ‘’;
if(str.match(/^[aeoiu]/g)){
pigLatin = str + ‘way’;
}else{
pigLatin = str.replace(/(^[^aeoiu]+)(\w+)/g, ‘$2$1ay’);
}

return pigLatin;
}

translatePigLatin(“consonant”);

why is the above code not working? The console returns “should handle words without vowels”


#2

What would you solution return for the word “TV”?


#3

The challenge does not specify. Can I make it anything?


#4

The challenge instructions state:

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”.

With a word like “TV”, if you move the letters “TV” to the end (technically no movement needed) and add “ay”, it would become “TVay”.


#5

Thank you very much. Really do appreciate it.


#6

Another example of a word without vowels would be “rhythm” which would become “rhythmay”