JavaScript Substitua espaços por traços
title = title.replace(/\s/g , "-");
Strange Sloth
title = title.replace(/\s/g , "-");
// replaces space with '-'
str = str.replace(/ /g, "-");
// or
str = str.split(' ').join('-');
let originalText = 'This is my text';
let dashedText = originalText.replace(/ /g, '-');
title = title.replace(/\s/g , "-");
var html = "<div>" + title + "</div>";
// ...
const text = "codetogo saved me tons of time";
text.replace(/ /g, "-");
let str = "This-is-a-news-item-";
str = str.replace(/-/g, ' ');
alert(str);