I am trying to use the following code to replace all the vowels from a string but it only works using regex. How can I use for of iteration?
// THIS DOES NOT WORK
newStr = '';
for (const c of "aeiou") {
console.log(c);
newStr = 'Hello World'.replace(c, '*');
}
console.log(newStr); // Prints Hello World to the console
// ONLY THIS WORKS
newStr = 'Hello World'.replace(/[aeiou]/g, '*');
console.log(newStr);