how to split a string to replace space with dashes javascript code example Example: javascript replace spaces with dashes title = title.replace(/\s/g , "-");