diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 046434c94..88e36b8d4 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -10,9 +10,25 @@ const rl = readline.createInterface({ function pigLatin(word) { - // Your code here +// Your code here + + +// for words that start with a vowel: + if (["a", "e", "i", "o", "u"].indexOf(word[0]) > -1) { + return word+"way"; + }else { +//check for multiple consonants + for (let i = 0; i -1){ + const firstCons = word.slice(0, i); + const middle = word.slice(i, word.length); + return middle+firstCons+"ay"; + } + } + } +}; + -} function getPrompt() {