Created
August 13, 2018 16:27
-
-
Save ferdelamad/168ea61b7469ce630eeb5f3f60479829 to your computer and use it in GitHub Desktop.
DoubleVowels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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