From 5d0a050339d91488855c28a3b8a514e9ebf25157 Mon Sep 17 00:00:00 2001 From: Jmirez2022 Date: Mon, 31 Oct 2022 10:02:23 -0500 Subject: [PATCH] finished --- README.md | 1 + main.js | 15 +++++++++++++-- package.json | 10 +++++----- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1054e0b..9af049ea 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ 1. Ensure you know how to run the unit test: * `npm test main.js` 1. Use a whiteboard to work out a solution to building the Pig Latin program +1. Use a whiteboard to work out a solution to building the Pig Latin program 1. Translate the broad ideas to pseudo code 1. Convert the pseudo code to real JavaScript Code 1. Type into your text editor the JavaScript code you've come up with one step at a time diff --git a/main.js b/main.js index 282f4c93..2566b05b 100644 --- a/main.js +++ b/main.js @@ -12,10 +12,21 @@ const rl = readline.createInterface({ const pigLatin = (word) => { - // Your code here - + word = word.toLowerCase().trim() + let vowels = ["a", "e", "i", "o", "u"]; + let newWord = '' + + if (vowels.includes(word[0])) { + return word + "yay"; + } else { + let arr = word.match(/[aeiou]/g) || 0; + let vIndex = word.indexOf(arr[0]); + newWord = word.slice(vIndex) + word.slice(0, vIndex) + 'ay'; + return newWord + } } +pigLatin("") // the first function called in the program to get an input from the user // to run the function use the command: node main.js diff --git a/package.json b/package.json index 3afb478f..261b7b2b 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,14 @@ }, "homepage": "https://github.com/AustinCodingAcademy/JS211_PigLatinProject#readme", "dependencies": { - "eslint": "^3.19.0", + "eslint": "^8.26.0", "functional-javascript-workshop": "^1.0.6", "htmllint-cli": "github:kevincolten/htmllint-cli", - "http-server": "^0.11.1", - "javascripting": "^2.6.1", - "jsdom": "^11.6.2", + "http-server": "^14.1.1", + "javascripting": "^2.4.0", + "jsdom": "^20.0.1", "mocha": "^5.0.0", "postcss-html": "^0.34.0", - "stylelint": "^7.13.0" + "stylelint": "^14.14.0" } }