A simple function that takes a string of words and returns them in pig latin.
-
splitstring by whitespace into an array of strings -
for loopthrough the array -
.mapthrough each string - ignoring all non-letter characters
-
ifselected string starts with a vowel add "way" to the end -
ifthe selected string starts with consonants,sliceall consonants before the first vowel (ifconsonants includes "qu" "u" is a consonant,) andpushthem onto the end of the selected string, add "ay" to the end of string -
joinall strings back into one long string