how to replace spaces in string in js code example
Example 1: javascript replace spaces with dashes
title = title.replace(/\s/g , "-");
Example 2: javascript replace spaces with br
str = str.replace(/\s/g, "<br>");
title = title.replace(/\s/g , "-");
str = str.replace(/\s/g, "<br>");