English to Pig Latin Translator - code challenge.
-Code challenge from www.edabit.com - https://edabit.com/challenge/uhsik73PY7Y2XftzG
Pig latin has two very simple rules:
If a word starts with a consonant move the first letter(s) of the word, till you reach a vowel, to the end of the word and add "ay" to the end.
have ➞ avehay
cram ➞ amcray
take ➞ aketay
cat ➞ atcay
shrimp ➞ impshray
trebuchet ➞ ebuchettray
If a word starts with a vowel add "yay" to the end of the word.
ate ➞ ateyay
apple ➞ appleyay
oaken ➞ oakenyay
eagle ➞ eagleyay
Write two functions to make an English to pig latin translator.
Write two functions to make an English to pig latin translator.
-
The first function TranslateWord(word) takes a single word and returns that word translated into pig latin.
-
The second function TranslateSentence(sentence) takes an English sentence and returns that sentence translated into pig latin.