remove more than one space in string javascript code example
Example 1: replace multiple spaces with single space javascript
string = string.replace(/\s\s+/g, ' ');
Example 2: javascript remove space from two side of string
const string = " this contains spaces ";
string.replace(/\s{2,}/g, '').trim()