Edit in JSFiddle

var myString = "He is such an ahole. I can't believe how much of a jackass he can be!";

var updateMyString = myString.replace(/ahole|jackass/g, function (s) {
    var i = 0;
    var hashs = "";
    while (i < s.length) {
        hashs += "*";
        i++;
    }
    return hashs;
});

console.log(updateMyString);
/*logs

He is such an *****. I can't believe how much of a ******* he can be!

*/