replace space wtih dashes in js code example
Example 1: replace all spaces with dash in javascript
title = title.replace(/\s/g , "-");
var html = "<div>" + title + "</div>";
// ...
Example 2: javascript replace all spaces with dashes
let originalText = 'This is my text';
let dashedText = originalText.replace(/ /g, '-');