title = title.replace(/\s/g , "-");
let originalText = 'This is my text'; let dashedText = originalText.replace(/ /g, '-');
title = title.replace(/\s/g , "-"); var html = "<div>" + title + "</div>"; // ...
str = str.replace(/\s/g, "<br>");
str = str.replace(/\s/g, " ");