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