From 0bd29f3dd310ede6a8581c509d0788b2a385b5cc Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Wed, 15 Jul 2020 17:43:59 -0500 Subject: [PATCH 1/9] first half with vowels running --- main.js | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 1c92f304..32854c6d 100644 --- a/main.js +++ b/main.js @@ -12,14 +12,46 @@ const rl = readline.createInterface({ const pigLatin = (word) => { + let finalWord = "" ; + let cleanWord = word.toLowerCase().trim() + let vowels = ['a', 'e', 'i', 'o', 'u'] ; + if (vowels.indexOf(cleanWord[0]) > -1) { + finalWord = cleanWord + "yay"; + return finalWord; + } + // else { + // let firstWord = word.match(/[aeiou]/g) || 0; + // let vowel = word.indexOf(firstWord[0]); + // finalWord = word.substring(vowel) + word.substring(0,vowel) + "ay"; + // return finalWord ; + - // Your code here + // { + // let finalWord = word.match(/[a,e,i,o,u]/g) + -} +console.log(pigLatin('anana')) + + + +// if word begins with consonant +// list the vowels: a, e, i, o, u ** +// run through string until we find the first vowel +// identify index position, store and use +// store sound before vowel in a variable (bucket) + +// splice out 'y' (first sound) +// concat/push 'y' (first sound) to end + +// concat 'ay' to the end + + } // the first function called in the program to get an input from the user // to run the function use the command: node main.js // to close it ctrl + C + + const getPrompt = () => { rl.question('word ', (answer) => { console.log( pigLatin(answer) ); From 7007210b3e4b7d4ad16e09cc4374c48a79a35f62 Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Wed, 15 Jul 2020 18:31:48 -0500 Subject: [PATCH 2/9] finished it baby --- main.js | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/main.js b/main.js index 32854c6d..940f6dc2 100644 --- a/main.js +++ b/main.js @@ -11,26 +11,23 @@ const rl = readline.createInterface({ }); + const pigLatin = (word) => { - let finalWord = "" ; + let vowels = ['a', 'e', 'i', 'o', 'u']; + let finalWord = ""; let cleanWord = word.toLowerCase().trim() - let vowels = ['a', 'e', 'i', 'o', 'u'] ; - if (vowels.indexOf(cleanWord[0]) > -1) { - finalWord = cleanWord + "yay"; - return finalWord; - } - // else { - // let firstWord = word.match(/[aeiou]/g) || 0; - // let vowel = word.indexOf(firstWord[0]); - // finalWord = word.substring(vowel) + word.substring(0,vowel) + "ay"; - // return finalWord ; - - - // { - // let finalWord = word.match(/[a,e,i,o,u]/g) - + if (vowels.indexOf(cleanWord[0]) > -1) { + finalWord = cleanWord + "yay"; + return finalWord; + } else { + let firstMatch = cleanWord.match(/[aeiou]/g) || 0; + let vowel = cleanWord.indexOf(firstMatch[0]); + finalWord = cleanWord.substring(vowel) + cleanWord.substring(0, vowel) + "ay"; + return finalWord; + } +} -console.log(pigLatin('anana')) +console.log(pigLatin('Blabama')) @@ -45,7 +42,7 @@ console.log(pigLatin('anana')) // concat 'ay' to the end - } + // the first function called in the program to get an input from the user // to run the function use the command: node main.js From 29155e903b3d831291655dfd0a1062fb21e32d3f Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Wed, 15 Jul 2020 18:48:15 -0500 Subject: [PATCH 3/9] some comments --- main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 940f6dc2..beb00e12 100644 --- a/main.js +++ b/main.js @@ -20,14 +20,15 @@ const pigLatin = (word) => { finalWord = cleanWord + "yay"; return finalWord; } else { + // we used a regex BOOM let firstMatch = cleanWord.match(/[aeiou]/g) || 0; - let vowel = cleanWord.indexOf(firstMatch[0]); - finalWord = cleanWord.substring(vowel) + cleanWord.substring(0, vowel) + "ay"; + let vowelIndex = cleanWord.indexOf(firstMatch[0]); + finalWord = cleanWord.substring(vowelIndex) + cleanWord.substring(0, vowelIndex) + "ay"; return finalWord; } } -console.log(pigLatin('Blabama')) +console.log(pigLatin('Alabama')) From cd4d2db4bb77c118710a17e89f3d50138a4f937a Mon Sep 17 00:00:00 2001 From: destinyfsetzer <54375774+destinyfsetzer@users.noreply.github.com> Date: Mon, 20 Jul 2020 17:59:23 -0500 Subject: [PATCH 4/9] created html element in javascript --- dom-main.js | 31 +++++++++++++++++++++++++++++++ index.html | 10 ++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 dom-main.js diff --git a/dom-main.js b/dom-main.js new file mode 100644 index 00000000..7d27e716 --- /dev/null +++ b/dom-main.js @@ -0,0 +1,31 @@ +let value = ""; + +const storeString = (valA) => { + value = valA + } + +const displayTranslation = (translatedWord) => { + var newDiv = document.createElement("P"); + newDiv.innerText = (translatedWord); + document.body.appendChild(newDiv); +} + +const pigLatin = () => { + let vowels = ['a', 'e', 'i', 'o', 'u']; + let finalWord = ""; + let cleanWord = value.toLowerCase().trim() + if (vowels.indexOf(cleanWord[0]) > -1) { + finalWord = cleanWord + "yay"; + return displayTranslation(finalWord) + } else { + let firstMatch = cleanWord.match(/[aeiou]/g) || 0; + let vowelIndex = cleanWord.indexOf(firstMatch[0]); + finalWord = cleanWord.substring(vowelIndex) + cleanWord.substring(0, vowelIndex) + "ay"; + return displayTranslation(finalWord) + } + } + + + + +// console.log(pigLatin('Alabama')) \ No newline at end of file diff --git a/index.html b/index.html index 8f536de8..fffe2999 100644 --- a/index.html +++ b/index.html @@ -2,14 +2,16 @@
-