function rep() { var str = 'Hello World'; str = setCharAt(str,4,'a'); console.log("replaced string is",str); } function setCharAt(str,index,chr) { if(index > str.length-1) return str; return str.substr(0,index) + chr + str.substr(index+1); } rep();
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more