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
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