From 8589c308962f8c454e5867cba399572e6f06a8e7 Mon Sep 17 00:00:00 2001 From: Daniel Vizueta Date: Sun, 26 Jun 2022 11:08:40 -0500 Subject: [PATCH 1/2] done --- main.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 282f4c93..cbcad76f 100644 --- a/main.js +++ b/main.js @@ -14,7 +14,22 @@ const rl = readline.createInterface({ const pigLatin = (word) => { // Your code here +let text = word.trim().toLowerCase() +const vowels = ["a","e","i","o","u"] +let newWord +if (vowels.includes(text[0])){ + newWord = text + "yay" +} +else { + for (let i = 0; i < text.length; i++){ + if (vowels.includes(text[i])) { + newWord = text.slice(i) + text.slice(0,i) + "ay" + break + } + } +} +return newWord } // the first function called in the program to get an input from the user @@ -26,7 +41,7 @@ const getPrompt = () => { getPrompt(); }); } - +pigLatin("cat"); // Unit Tests // to use them run the command: npm test main.js // to close them ctrl + C From a62bf680dc7e3b52e3e6625e58cb7ff270b19549 Mon Sep 17 00:00:00 2001 From: Daniel Vizueta Date: Mon, 4 Jul 2022 12:20:31 -0500 Subject: [PATCH 2/2] done --- index.html | 6 ++++-- index.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 index.js diff --git a/index.html b/index.html index 16517707..5124c484 100644 --- a/index.html +++ b/index.html @@ -3,16 +3,18 @@ - +

Hello World!


+
- + +

diff --git a/index.js b/index.js new file mode 100644 index 00000000..65b9fed5 --- /dev/null +++ b/index.js @@ -0,0 +1,31 @@ +const userInput = document.getElementById("user-input") +const output = document.getElementById("display-element") +const translateWord = (event) => { + event.preventDefault() + // console.log(userInput.value) + const newWord = pigLatin(userInput.value) + output.innerText = newWord +console.log(newWord) +} + + +const pigLatin = (word) => { + + // Your code here + let text = word.trim().toLowerCase() + const vowels = ["a","e","i","o","u"] + let newWord + if (vowels.includes(text[0])){ + newWord = text + "yay" + } + else { + for (let i = 0; i < text.length; i++){ + if (vowels.includes(text[i])) { + newWord = text.slice(i) + text.slice(0,i) + "ay" + break + } + } + } + + return newWord + } \ No newline at end of file