Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save betterkenly/963de4e1d0d75acfc0f2ec58eb24aab3 to your computer and use it in GitHub Desktop.
Save betterkenly/963de4e1d0d75acfc0f2ec58eb24aab3 to your computer and use it in GitHub Desktop.
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