Hello coders,
I’m trying to write a function, that will take an array as a parameter. I want to return a new array, but with vowels replaced by '’.
Example : ["h’, “i”] => should be [“h”, ""]
I’m just getting [ " * " ] and not the remaining array elements.
Please help!
function replaceVowels (arr) {
let vowels = [‘a’, ‘e’, ‘i’, ‘o’, ‘u’] ;
let result = [ ];
for ( let i=0; i< arr.length; i++) {
if ( ! vowels.includes(arr[i])) {
arr[i] = ’ * ';
result.push(arr[i]);
}
}
return result;
}
replaceVowels([“h”, “i”]);