js replace character in string by index code example
Example 1: javascript string change character at index
String.prototype.replaceAt=function(index, char) {
var a = this.split("");
a[index] = char;
return a.join("");
}
Example 2: string one char change in typescript
let hello:string = "Hello World";
console.log(hello.replaceAt(2, "!!")); // Should display He!!o World