From 626c6871913669c14586617e79459aca349b442b Mon Sep 17 00:00:00 2001 From: DavidStephenss Date: Sun, 19 Jul 2020 23:43:26 -0500 Subject: [PATCH 1/3] doin stuff --- main.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.js b/main.js index 1c92f304..f2018595 100644 --- a/main.js +++ b/main.js @@ -11,8 +11,16 @@ const rl = readline.createInterface({ }); + const pigLatin = (word) => { + let value ="" + let vowel =['a','e', 'i', 'o', 'u'] + let value = word.toLowerCase().trim()
.split("") +if (let i = 0; word === vowel) { + return Word.concat('yay') + let word = .split(""); +} // Your code here } From b420495ecf4993882c0374b00c2bb96a17665441 Mon Sep 17 00:00:00 2001 From: DavidStephenss Date: Mon, 20 Jul 2020 00:14:19 -0500 Subject: [PATCH 2/3] 4passing --- main.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/main.js b/main.js index f2018595..509ce139 100644 --- a/main.js +++ b/main.js @@ -13,17 +13,27 @@ const rl = readline.createInterface({ const pigLatin = (word) => { - let value ="" - let vowel =['a','e', 'i', 'o', 'u'] - let value = word.toLowerCase().trim()
.split("") -if (let i = 0; word === vowel) { - return Word.concat('yay') - - let word = .split(""); -} + let vowels = ["a", "e", "i", "o", "u"]; + let finalWord = ""; + // scrub the data + let cleanWord = word.toLowerCase().trim(); + // if word begins with vowel add 'yay' + if (vowels.indexOf(cleanWord[0]) > -1) { + finalWord = cleanWord + "yay"; // Your code here - + return finalWord; +} +// if word begins with consonant +else { + // run through string until we find the first vowel. What match() does is it returns an array of all the character indexes that match our regular expression pattern. Our pattern looks at any character that is a vowel. If there are no vowels, then we assign firstMatch the value of 0. + let firstMatch = cleanWord.match(/[aeiou]/g) || 0; + // index of the first vowel found in the string using indexOf() + let vowelIndex = cleanWord.indexOf(firstMatch[0]); + //string without the consonant beginning + the consonant + ay + finalWord = cleanWord.substring(vowelIndex) + cleanWord.substring(0, vowelIndex) + "ay"; + return finalWord; } +}; // 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 02638c73b5ebd6fc4c321210a6c73dbfe7b53394 Mon Sep 17 00:00:00 2001 From: DavidStephenss Date: Sun, 26 Jul 2020 12:36:46 -0500 Subject: [PATCH 3/3] dom --- dom.js | 26 ++++++++++++++++++++++++++ index.html | 28 +++++++++++++++------------- 2 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 dom.js diff --git a/dom.js b/dom.js new file mode 100644 index 00000000..1b5cd6b6 --- /dev/null +++ b/dom.js @@ -0,0 +1,26 @@ + +const storeString = (valA) => { + value = valA + } + + const displayTranslation = (translatedWord) => { + // document.getElementById("results").innerHTML = translatedWord + document.createElement('results') + // let newElement = document.createElement("P"); + // newElement.appendChild(translatedWord); + } + + 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) + } + } \ No newline at end of file diff --git a/index.html b/index.html index 8f536de8..30318673 100644 --- a/index.html +++ b/index.html @@ -1,15 +1,17 @@ - - - - - - -

Hello World!

-
-
- -
- - + + +Pig Latin + + +

Let's do Pig Latin Stuff!

+
+
+ + +
+
+ + + \ No newline at end of file