Can someone elucidate a method that will swap all vowel occurrences in a string with the char 'i'.
For a user input of "Hello world!", "Hilli wirld!" should be returned.
Method below can only remove vowels, rather than replacing them with a chosen char. I do not want to use string replace. I must take a more laborious route of manipulating the array.
function withoutVowels(string) {
var withoutVowels = "";
for (var i = 0; i < string.length; i++) {
if (!isVowel(string[i])) {
withoutVowels += string[i];
}
}
return withoutVowels;
}
function isVowel(char) {
return 'aeiou'.includes(char);
}
console.log(withoutVowels('Hello World!'));