var str = " a b    c d e   f g   ";
var newStr = str.trim();
// "a b    c d e   f g"