replacing spaces with dashes js code example Example: javascript replace spaces with dashes title = title.replace(/\s/g , "-");