Here is my code, I want to replace vowels in a string with the index values but when I was running the code I’m getting an error called “TypeError: val.replaceAll is not a function”.
I also used replace() method(got 2 l3v1 j0vasscript) in place of replaceAll() method but I didn’t get the desired output.
let val = "I love JavasScript";
val = val.toLowerCase();
let vowels = ['a', 'e', 'i', 'o', 'u'];
vowels.forEach((letter, index) => {
val = val.replace(letter, index);
});
console.log(val);