Skip to content

Instantly share code, notes, and snippets.

@ferdelamad
Created August 13, 2018 16:27
Show Gist options
  • Save ferdelamad/168ea61b7469ce630eeb5f3f60479829 to your computer and use it in GitHub Desktop.
Save ferdelamad/168ea61b7469ce630eeb5f3f60479829 to your computer and use it in GitHub Desktop.
DoubleVowels
//input = array of individual chars.
//ouput = same array with double the amount of vowels.
const doubleVowels = array => {
for (let index = array.length - 1; index >= 0; index--) {
if (checkForWowels(array[index])) {
array.splice(index, 0, array[index]);
index--;
}
}
return array;
};
const checkForWowels = str => {
str = str.toLowerCase();
if (str === "a" || str === "e" || str === "i" || str === "o" || str === "u") {
return true;
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment