1// replaces space with '-'
2str = str.replace(/ /g, "-");
3// or
4str = str.split(' ').join('-');
1let originalText = 'This is my text';
2let dashedText = originalText.replace(/ /g, '-');
1title = title.replace(/\s/g , "-");
2var html = "<div>" + title + "</div>";
3// ...
1const str = "Sonic Free Games";
2str = str.replace(/\s+/g, '-').toLowerCase();
3console.log(str); // "sonic-free-games"
4