title = title.replace(/s/g , "-");
// replaces space with '-'
str = str.replace(/ /g, "-");
// or
str = str.split(' ').join('-');
var str = "Sonic Free Games";
str = str.replace(/s+/g, '-').toLowerCase();
console.log(str); // "sonic-free-games"
const str = "Sonic Free Games";
str = str.replace(/s+/g, '-').toLowerCase();
console.log(str); // "sonic-free-games"
let str = "This-is-a-news-item-";
str = str.replace(/-/g, ' ');
alert(str); //This is a news item