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