For the computationally inclined, a brief decription of how it works:
- User's English input is stored as a string.
- Javascript splits the string into an array of strings with a space being the delimiter.
- Then, our function loops through the array and provides a few analyses:
- If the last character of a word is a punctuation mark, we remove it from the string and store it as a temporary variable.
- If the first two letters are in the array of English acceptable onsets ("sh","th" as an example) we move the first two chars to the end of the word.
- If the first character is a vowel, nothing is done.
- Then add the word with the characters at the end with "ay" and finally the punctuation mark if there was one present.