javascript string spaces replace code example
Example 1: javascript replace spaces with dashes
title = title.replace(/\s/g , "-");
Example 2: replace white spaces javascript
const name = 'Hi my name is Flavio'
name.replace(/\s/g, '') //HimynameisFlavio