Created
July 17, 2017 16:41
-
-
Save betterkenly/963de4e1d0d75acfc0f2ec58eb24aab3 to your computer and use it in GitHub Desktop.
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
var arr = 'what on earth are you talking about'.split(''); | |
// var vowelDoubler = (str) => { | |
// return str.replace(/[a||e||i||o||u]/gi, myFunc).split(''); | |
// }; | |
var vowelTest = (str) => { | |
if (str.match(/[a||e||i||o||u]/gi)) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
// var myFunc = (str) => { | |
// if (vowelTest(str)) { | |
// return str + str; | |
// } | |
// } | |
// console.log(vowelTest('b')); | |
// console.log(vowelDoubler(string)); | |
var vowelDoubler = (arr) => { | |
for (var i = 0; i < arr.length; i++) { | |
var curr = arr[i]; | |
if (vowelTest(curr)) { | |
arr.splice(i, 0, curr); | |
i++; | |
} | |
} | |
return arr; | |
} | |
console.log(vowelDoubler(arr)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment