From 947068448b1bf17c4772eaee8373311696e2aace Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Tue, 17 Oct 2017 22:04:52 -0500 Subject: [PATCH 1/5] comments to piglatin --- 02week/pigLatin.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 046434c94..f49a19b6b 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -49,3 +49,22 @@ if (typeof describe === 'function') { getPrompt(); } + + +// Global Storage, what do I need to keep on the largest scope +// None I can think of maybe using a variable = 'ay'? + +//Break the string into an array, method to use +// const stringToArray , using word.split(',') + +// Save the first value in the array, method to use +// Using a const firstLetter = stringToArray[0] + +// Remove the first letter, method to use +// const removeFirstLetter = using stringToArray.shift() as the method + +//Name of function, turning the array back into a string, method to use +// const removeFirstLetter using .join() + +//Function to join the variable to the rest of the string and add "ay" +// Return the var of + removeFirstLetter + "ay" From d8200b93d88e0573c33552e40452cac4cc45335d Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Thu, 19 Oct 2017 14:23:56 -0500 Subject: [PATCH 2/5] everything but lowercase --- 02week/pigLatin.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index f49a19b6b..6e2abd91b 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -9,11 +9,18 @@ const rl = readline.createInterface({ function pigLatin(word) { - - // Your code here - + const splitWord = word.split('') + if (splitWord[0] === 'a' || splitWord[0] === 'e' || splitWord[0] === 'i' || splitWord[0] === 'o' || splitWord[0] === 'u'){ + return word + 'yay' + } else { + const firstLetter = splitWord.shift(); + const removeFirstLetter = splitWord.join(''); + return removeFirstLetter + firstLetter + 'ay'; + } } +pigLatin(); + function getPrompt() { rl.question('word ', (answer) => { From 85f99fc03f381dc9894809c19df8d1efe0ff927c Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Thu, 19 Oct 2017 14:43:17 -0500 Subject: [PATCH 3/5] uppercase meet your maker --- 02week/pigLatin.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 6e2abd91b..6715a2673 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -9,14 +9,15 @@ const rl = readline.createInterface({ function pigLatin(word) { - const splitWord = word.split('') - if (splitWord[0] === 'a' || splitWord[0] === 'e' || splitWord[0] === 'i' || splitWord[0] === 'o' || splitWord[0] === 'u'){ - return word + 'yay' - } else { - const firstLetter = splitWord.shift(); - const removeFirstLetter = splitWord.join(''); - return removeFirstLetter + firstLetter + 'ay'; - } + const lowerThatCase = word.toLowerCase(); + const splitWord = lowerThatCase.split('') + if (splitWord[0] === 'a' || splitWord[0] === 'e' || splitWord[0] === 'i' || splitWord[0] === 'o' || splitWord[0] === 'u'){ + return word + 'yay' + } else { + const firstLetter = splitWord.shift(); + const removeFirstLetter = splitWord.join(''); + return removeFirstLetter + firstLetter + 'ay'; + } } pigLatin(); From 4fa05a8cc096c4b7bedc1d3f481df25e1f19c33e Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Thu, 19 Oct 2017 15:05:04 -0500 Subject: [PATCH 4/5] comments yo --- 02week/pigLatin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 6715a2673..71fa44bba 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -9,8 +9,11 @@ const rl = readline.createInterface({ function pigLatin(word) { + // make (word) all lowercase const lowerThatCase = word.toLowerCase(); + // make that into array const splitWord = lowerThatCase.split('') + // check if any vowels if not move on to normalcy if (splitWord[0] === 'a' || splitWord[0] === 'e' || splitWord[0] === 'i' || splitWord[0] === 'o' || splitWord[0] === 'u'){ return word + 'yay' } else { From eace488917bea6100b12babede021957f73ad0f1 Mon Sep 17 00:00:00 2001 From: cfissell50 Date: Thu, 19 Oct 2017 17:36:47 -0500 Subject: [PATCH 5/5] i r dun --- 02week/pigLatin.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/02week/pigLatin.js b/02week/pigLatin.js index 71fa44bba..4cbd65113 100644 --- a/02week/pigLatin.js +++ b/02week/pigLatin.js @@ -10,20 +10,20 @@ const rl = readline.createInterface({ function pigLatin(word) { // make (word) all lowercase - const lowerThatCase = word.toLowerCase(); + const lowerThatCase = word.toLowerCase().trim(); // make that into array - const splitWord = lowerThatCase.split('') + const splitWord = lowerThatCase.split(''); // check if any vowels if not move on to normalcy - if (splitWord[0] === 'a' || splitWord[0] === 'e' || splitWord[0] === 'i' || splitWord[0] === 'o' || splitWord[0] === 'u'){ - return word + 'yay' - } else { - const firstLetter = splitWord.shift(); - const removeFirstLetter = splitWord.join(''); - return removeFirstLetter + firstLetter + 'ay'; - } + if (splitWord[0] === 'a' || splitWord[0] === 'e' || splitWord[0] === 'i' || splitWord[0] === 'o' || splitWord[0] === 'u'){ + return lowerThatCase + 'yay'; + } else { + const firstLetter = splitWord.shift(); + const removeFirstLetter = splitWord.join(''); + return removeFirstLetter + firstLetter + 'ay'; + } } -pigLatin(); +pigLatin('ALEX'); function getPrompt() {