Todashcase JavaScript

let str = "Sample text";
let str2 = str.replace(/[" "]/g,"-");
console.log(str2); // Sample-text
Thurinum