Theme Night

Js replace spaces with dashes

//replace spaces with dashes
const text = "codetogo saved me tons of time";
text.replace(/ /g, "-");

//replace space with hyphen/dash javascript
const str = "Sonic Free Games";
str = str.replace(/\s+/g, '-').toLowerCase();
console.log(str); // "sonic-free-games"

//replace all spaces with dash in javascript
title = title.replace(/\s/g , "-");
var html = "<div>" + title + "</div>";

//javascript replace all spaces with dashes
let originalText = 'This is my text';
let dashedText = originalText.replace(/ /g, '-');

//js replace space with dash
// replaces space with '-'
str = str.replace(/ /g, "-");
// or
str = str.split(' ').join('-');

//javascript replace spaces with dashes
title = title.replace(/\s/g , "-");

Related Code