How in JS to subtract from the string a certain phrase?

For example:
Incoming string : privatekey. We need to cut "as"
To get the phrase "privately"
July 2nd 19 at 16:59
2 answers
July 2nd 19 at 17:01
Solution
var str = 'privatekey';
str = str.replace(/how/gi,");
alert(str)
July 2nd 19 at 17:03
Solution
Method times:
var str = 'privatekey';
console.log(str.split('as').join(")); // privately

Method two:
var str = 'privatekey';
console.log(str.replace('as', ")); // privately

Find more questions by tags jQueryJavaScript