From c6d8394f707cb2b4f4542f2429e8b412c7d1abdd Mon Sep 17 00:00:00 2001 From: ddiza Date: Mon, 3 Jul 2023 11:09:46 -0500 Subject: [PATCH 1/4] initial commit --- main.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 282f4c93..4d405893 100644 --- a/main.js +++ b/main.js @@ -9,7 +9,24 @@ const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); - +/** takes a word (string) as an input +* makes input lowercase and trim +* +* +* +*FOR LOOP TO CHECK: +* if word starts with consonant, remove 1st letter, move it to end, add ay +* if word starts with 2 consonants, remove 1st 2 letters, put them at end, add ay +* if word starts with a vowel, add yay +* +* Start: +* ==> Need array variable to hold consonant or vowels +* ==> Less vowels to check, so start here. +* Assumptions: +* vowels are a e i o u +* +* +*/ const pigLatin = (word) => { From 5de205228ab237eb0c20d824bbb26b701024904d Mon Sep 17 00:00:00 2001 From: ddiza Date: Mon, 3 Jul 2023 11:51:16 -0500 Subject: [PATCH 2/4] updated main.js --- main.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 4d405893..42b57811 100644 --- a/main.js +++ b/main.js @@ -9,7 +9,33 @@ const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); -/** takes a word (string) as an input + +const pigLatin = (word) => { + + // Your code here + let inputWord = word.trim().toLowerCase(); + let vowels = ['a', 'e', 'i', 'o', 'u']; + + for (let i = 0; i< inputWord.length; i++) { + // word starts with a vowel, + if(vowels.includes(inputWord[0])) { + let newWord = inputWord + "yay" + return newWord; + } else if (!vowels.includes(inputWord[0]) && !vowels.includes(inputWord[1])) { + // word starts with one consonant + // remove the first letter, put it at the end, add ay + + let newWord = inputWord.slice(2) + inputWord.slice(0,2) + "ay" + return newWord + + } else { + let newWord = inputWord.slice(1) + inputWord.slice(0,1) + "ay" + return newWord + + } + } + + /** takes a word (string) as an input * makes input lowercase and trim * * @@ -28,10 +54,6 @@ const rl = readline.createInterface({ * */ -const pigLatin = (word) => { - - // Your code here - } // the first function called in the program to get an input from the user From f92d5de3a936162b1ea3f959ba37ee6de300148f Mon Sep 17 00:00:00 2001 From: ddiza Date: Sun, 9 Jul 2023 22:01:49 -0500 Subject: [PATCH 3/4] updated files --- index.html | 13 ++++++++----- main-dom.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 +++++- 3 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 main-dom.js diff --git a/index.html b/index.html index 16517707..1c8b9f4a 100644 --- a/index.html +++ b/index.html @@ -2,18 +2,21 @@ - - + Pig Latin

Hello World!


-
-
+ + -
+
+
+ + + diff --git a/main-dom.js b/main-dom.js new file mode 100644 index 00000000..c7e5e38f --- /dev/null +++ b/main-dom.js @@ -0,0 +1,46 @@ +'use strict'; + + +const pigLatin = () => { + //get the value from the html form input + let word = document.getElementById("user-input").value; + + let inputWord = word.trim().toLowerCase(); + + let vowels = ['a', 'e', 'i', 'o', 'u']; + + for (let i = 0; i< inputWord.length; i++) { + // word starts with a vowel, + if(vowels.includes(inputWord[0])) { + let newWord = inputWord + "yay" + + // return the newWord to the DOM, directly inside display-element div + + document.getElementById('display-element').innerHTML = newWord + + // return to the console + // return newWord; + } else if + (!vowels.includes(inputWord[0]) && + !vowels.includes(inputWord[1]) + ) { + // word starts with one consonant + // remove the first letter, put it at the end, add ay + + let newWord = inputWord.slice(2) + inputWord.slice(0,2) + "ay" + document.getElementById('display-element').innerHTML = newWord + + // return newWord + + } else { + let newWord = inputWord.slice(1) + inputWord.slice(0,1) + "ay" + document.getElementById('display-element').innerHTML = newWord + + // return newWord + + } + } + + +} + diff --git a/package.json b/package.json index 3afb478f..b9a1e1ad 100644 --- a/package.json +++ b/package.json @@ -28,5 +28,9 @@ "mocha": "^5.0.0", "postcss-html": "^0.34.0", "stylelint": "^7.13.0" - } + }, + "main": "main.js", + "devDependencies": {}, + "keywords": [], + "license": "ISC" } From bb44ad2295e64ec73017911a7042e14238a2e0dc Mon Sep 17 00:00:00 2001 From: ddiza Date: Sun, 9 Jul 2023 22:14:33 -0500 Subject: [PATCH 4/4] updated w/style.css --- index.html | 1 + style.css | 0 2 files changed, 1 insertion(+) create mode 100644 style.css diff --git a/index.html b/index.html index 1c8b9f4a..7b8ed08f 100644 --- a/index.html +++ b/index.html @@ -3,6 +3,7 @@ Pig Latin +

Hello World!

diff --git a/style.css b/style.css new file mode 100644 index 00000000..e69de29b