Mengganti karakter dalam string javascript
var myStr = 'this,is,a,test';
var newStr = myStr.replace(/,/g, '-');
console.log( newStr ); // "this-is-a-test"
Exuberant Emu
var myStr = 'this,is,a,test';
var newStr = myStr.replace(/,/g, '-');
console.log( newStr ); // "this-is-a-test"
var str = "JavaScript replace method test";
var res = str.replace("test", "success");
//res = Javscript replace method success
let string = 'soandso, my name is soandso';
let replaced = string.replace(/soandso/gi, 'Dylan');
console.log(replaced); //Dylan, my name is Dylan