in javascript the following is returning an error saying that hello.replaceAt is not a function, that hello.replaceAt is undefined.
    var hello = 'Hello World';
    alert(hello.replaceAt(2, "!!"));
Why is this not working? Thanks.
in javascript the following is returning an error saying that hello.replaceAt is not a function, that hello.replaceAt is undefined.
    var hello = 'Hello World';
    alert(hello.replaceAt(2, "!!"));
Why is this not working? Thanks.
 
    
    Using replace():
var hello = 'Hello World!!';
    alert(hello.replace("!!",'??'));
If you want to replace all matchs in a string you can use this funct
String.prototype.replaceAll = function(search, replacement) {
    var target = this;
    return target.split(search).join(replacement);
};
Because .replace() just replace first match.
Cheers
 
    
    function myFunction() {
    var str = document.getElementById("demo").innerHTML; 
    var res = str.replace("!!", "...!!");
    document.getElementById("demo").innerHTML = res;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="demo">Hello world!!</p>
<button onclick="myFunction()">Try it</button>Check this out. Help you to get some idea.
Greetings!
