From 80123712fdd89e61a1023deb5d2bb9c8dfe69a65 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Wed, 18 Oct 2017 20:25:44 -0500 Subject: [PATCH 1/8] Still need to figure out the for loop and indexOf --- 02week/pigLatin.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 046434c94..af89ce589 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -1,5 +1,17 @@ 'use strict'; +//global storage + //const pigLatinStr = ('choose your word here') => {} + //const vowels = ('aeiou') + +//function names, purpose, method + //checkFirstVowel(), use a for loop to look for where the first vowel is in the array, indexOf method + //strToArray(), convert the word you used into an array, split method, split on first vowel index + //moveToEnd(), move all array elements before the first vowel to the end, use push and shift method with value returned from indexOf + //addAY(), add the letters a and y to the end of the array, push method + //arrayToStr(), convert the array back into a string, join method + //print out result + const assert = require('assert'); const readline = require('readline'); const rl = readline.createInterface({ @@ -8,11 +20,17 @@ const rl = readline.createInterface({ }); -function pigLatin(word) { +const pigLatinr=(word)=> { + //checkFirstVowel goes here!!! + word.split(``); + word.push(`ay`); + word.join(``); + return word; +} + +pigLatin(`scram`); - // Your code here -} function getPrompt() { From 37c1336c8d5e42694eda7aa1be749eee6578a2a3 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 19 Oct 2017 18:26:24 -0500 Subject: [PATCH 2/8] researching the match method to figure out vowels --- 02week/pigLatin.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index af89ce589..d645fd925 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -21,6 +21,8 @@ const rl = readline.createInterface({ const pigLatinr=(word)=> { + const lowerCase = word.toLowerCase().trim() + //checkFirstVowel goes here!!! word.split(``); word.push(`ay`); From a4ca50d7375190f21fcb2cdd50990c624d9c834c Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 19 Oct 2017 20:08:04 -0500 Subject: [PATCH 3/8] researching the match method to figure out vowels, learned more about indexOf --- 02week/pigLatin.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index d645fd925..f2c6f4835 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -20,9 +20,10 @@ const rl = readline.createInterface({ }); -const pigLatinr=(word)=> { - const lowerCase = word.toLowerCase().trim() - +const pigLatin=(word)=> { + word.toLowerCase().trim(); + const arrVowels = ['a', 'e', 'i', 'o', 'u'] + for (let arrVowels = ) //checkFirstVowel goes here!!! word.split(``); word.push(`ay`); From 74cf90c2c5455652d56aeb99ee43ace0ec248136 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Sat, 21 Oct 2017 15:11:21 -0500 Subject: [PATCH 4/8] took a break, was getting down the rabbit hole lost what I should be doing --- 02week/pigLatin.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index f2c6f4835..8f5717947 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -22,10 +22,14 @@ const rl = readline.createInterface({ const pigLatin=(word)=> { word.toLowerCase().trim(); - const arrVowels = ['a', 'e', 'i', 'o', 'u'] - for (let arrVowels = ) - //checkFirstVowel goes here!!! word.split(``); + + //checkFirstVowel goes here!!! + const searchVowel=(arrVowels)=> { + return arrVowels === ['a', 'e', 'i', 'o', 'u'] + } + word.copyWithin(searchVowel[0], ); + //moveToEnd(), move consonants before the first vowel to the end of the word, word.push(`ay`); word.join(``); return word; From d26a7a1fa64d8379c74ee640a9eb30a6f1753c03 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Tue, 24 Oct 2017 18:46:08 -0500 Subject: [PATCH 5/8] need to commit to switch branches --- 02week/pigLatin.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 8f5717947..c1936c857 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -23,11 +23,11 @@ const rl = readline.createInterface({ const pigLatin=(word)=> { word.toLowerCase().trim(); word.split(``); - + //slice, indexOf, concat //checkFirstVowel goes here!!! - const searchVowel=(arrVowels)=> { - return arrVowels === ['a', 'e', 'i', 'o', 'u'] - } + let firstVowel; + const vowel = ['a', 'e', 'i', 'o', 'u'] + vowel.forEach=()=> word.copyWithin(searchVowel[0], ); //moveToEnd(), move consonants before the first vowel to the end of the word, word.push(`ay`); From 590209f008bb004d77b271ef5d91aeba3e7ac2e8 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Wed, 25 Oct 2017 19:32:35 -0500 Subject: [PATCH 6/8] figuring out piglatin and how to use foreach --- 02week/pigLatin.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index c1936c857..011ee3fbb 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -5,12 +5,9 @@ //const vowels = ('aeiou') //function names, purpose, method - //checkFirstVowel(), use a for loop to look for where the first vowel is in the array, indexOf method - //strToArray(), convert the word you used into an array, split method, split on first vowel index - //moveToEnd(), move all array elements before the first vowel to the end, use push and shift method with value returned from indexOf - //addAY(), add the letters a and y to the end of the array, push method - //arrayToStr(), convert the array back into a string, join method - //print out result + //convert your word to lower case, toLowerCase method + //get rid of any empty space, trim method, chained to toLowerCase + // const assert = require('assert'); const readline = require('readline'); @@ -22,11 +19,13 @@ const rl = readline.createInterface({ const pigLatin=(word)=> { word.toLowerCase().trim(); - word.split(``); + const vowel = ['a', 'e', 'i', 'o', 'u'] + vowels.forEach(indexOf(word){ + + }); //slice, indexOf, concat //checkFirstVowel goes here!!! let firstVowel; - const vowel = ['a', 'e', 'i', 'o', 'u'] vowel.forEach=()=> word.copyWithin(searchVowel[0], ); //moveToEnd(), move consonants before the first vowel to the end of the word, From f3c25c35de604b325ac16f5d594e7ad51f62c1d9 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Thu, 26 Oct 2017 06:27:02 -0500 Subject: [PATCH 7/8] still trying to figure out how to integrate indexOf into forEach --- 02week/pigLatin.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 011ee3fbb..61e918383 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -7,7 +7,7 @@ //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'); @@ -20,7 +20,10 @@ const rl = readline.createInterface({ const pigLatin=(word)=> { word.toLowerCase().trim(); const vowel = ['a', 'e', 'i', 'o', 'u'] - vowels.forEach(indexOf(word){ + const vowelIndex =(word)=>{ + return word.indexOf(); + } + vowels.forEach(vowelIndex(word){ }); //slice, indexOf, concat From ded212bafa1a07ed9f70c34c5e6cc31d16847a10 Mon Sep 17 00:00:00 2001 From: walzer85 Date: Sun, 29 Oct 2017 07:48:39 -0500 Subject: [PATCH 8/8] Still need to figure out how to return the first vowel indexgit branch --- 02week/pigLatin.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 61e918383..0d74a0453 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -19,13 +19,13 @@ const rl = readline.createInterface({ const pigLatin=(word)=> { word.toLowerCase().trim(); + const wordArr=word.split(); const vowel = ['a', 'e', 'i', 'o', 'u'] - const vowelIndex =(word)=>{ - return word.indexOf(); + wordArr.forEach((letter, i) => { + if(vowel.indexOf(letter)!==-1){ + return vowel; } - vowels.forEach(vowelIndex(word){ - - }); +}); //slice, indexOf, concat //checkFirstVowel goes here!!! let firstVowel;