I want to obtain the neighboring characters that are not vowels, but it does not show me all, the code below is what I try but it does not fulfill my objective.
function solve(s) {
s = s.split('');
let res = '';
let array = [];
array = s.map((value, idx, arr) =>
(!vocal(value) && !vocal(arr[idx - 1]) && typeof arr[idx - 1] !== 'undefined') ?
res + value : res = ''
)
console.log(array);
return 0;
};
function vocal(a) {
let res = false;
switch (a) {
case 'a':
res = true;
break;
case 'e':
res = true;
break;
case 'i':
res = true;
break;
case 'o':
res = true;
break;
case 'u':
res = true;
break;
}
return res;
}
solve('hhollliillapiiii');
Expected result: [hh, lll, ll], the p character has no neighbor that is not a vowel so it should not enter.