how to remove extra spaces in a string js code example
Example 1: remove spaces in a string js
str.replace(/\s+/g, '')
Example 2: remove extra space in string javascript
newString = string.replace(/\s+/g,' ').trim();
str.replace(/\s+/g, '')
newString = string.replace(/\s+/g,' ').trim();