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