function rep() {
var str = 'Hello World';
str = setCharAt(str,4,'a');
alert(str);
}
function setCharAt(str,index,chr) {
if(index > str.length-1) return str;
return str.substring(0,index) + chr + str.substring(index+1);
}
String.prototype.replaceAt=function(index, char) {
var a = this.split("");
a[index] = char;
return a.join("");
}
let string = 'bob'
let index = 2
string = string.substring(0, index) + 'x' + string.substring(index + 1)
console.log(string) // [Log]: box
str = 'INPUT HERE'
str = str.split('');
str[3] = 'O';
str = str.join('');
//Output: INPOT HERE
//Why does 3 replace the fourth character?
//Almost all rogramming languages start to count from zero.
//0 = first, 1 = second...