diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 046434c94..0d74a0453 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -1,5 +1,14 @@ 'use strict'; +//global storage + //const pigLatinStr = ('choose your word here') => {} + //const vowels = ('aeiou') + +//function names, purpose, method + //convert your word to lower case, toLowerCase method + //get rid of any empty space, trim method, chained to toLowerCase + //vowelIndex(), use this inside of a forEach method to find the index of the vowels in the word, indexOf method + const assert = require('assert'); const readline = require('readline'); const rl = readline.createInterface({ @@ -8,11 +17,29 @@ const rl = readline.createInterface({ }); -function pigLatin(word) { +const pigLatin=(word)=> { + word.toLowerCase().trim(); + const wordArr=word.split(); + const vowel = ['a', 'e', 'i', 'o', 'u'] + wordArr.forEach((letter, i) => { + if(vowel.indexOf(letter)!==-1){ + return vowel; + } +}); + //slice, indexOf, concat + //checkFirstVowel goes here!!! + let firstVowel; + vowel.forEach=()=> + word.copyWithin(searchVowel[0], ); + //moveToEnd(), move consonants before the first vowel to the end of the word, + word.push(`ay`); + word.join(``); + return word; +} + +pigLatin(`scram`); - // Your code here -} function getPrompt() {