JavaScript Substitua espaços por traços
title = title.replace(/\s/g , "-");
Strange Sloth
title = title.replace(/\s/g , "-");
input = "Hello my name is Luke"
inputWithoutSpaces = input.replace(/\s/g, "_"); // \s == space
console.log(inputWithoutSpaces); //Output: "Hello_my_name_is_Luke"