I want to write a function that replaces all the vowels (a,e,i,o,u) in a string and keeps one separator ('') between consonants. For example:
Input: 'kkkeoiekkk'
Output: ['kkk', '', 'kkk']
My try:
function split(para) {
let regex = /[a|e|i|o|u]/g;
let arr = para.replace(regex, '-').split('-');
for (let i = 0; i < str.length; i++) {
if (arr[i] === '' && arr[i - 1] === '') {}
}
return arr
}
Right now for the input split('hheeooook') I get back [ 'h', '', '', '', 'k' ] instead of ['h', '', 'k']. Thanks for everyone reading or pointing out what is wrong with my function.