Updated file paths

This commit is contained in:
thatblindgeye
2023-02-01 18:53:54 -05:00
parent a092bf0559
commit 2ec0f4344d
24 changed files with 207 additions and 204 deletions
@@ -0,0 +1,21 @@
const pigLatin = function (string) {
return string
.split(" ")
.map((word) => {
const index = firstVowelIndex(word);
const beginning = word.slice(0, index);
const ending = word.slice(index);
return `${ending}${beginning}ay`;
})
.join(" ");
};
const firstVowelIndex = function (string) {
const vowels = string.match(/[aeiou]/g);
if (vowels[0] == "u" && string[string.indexOf(vowels[0]) - 1] == "q") {
return string.indexOf(vowels[1]);
}
return string.indexOf(vowels[0]);
};
module.exports = pigLatin;