how to trim all white spaces in sentence javacript code example Example: remove whitespace javascript var str = " Some text "; str.trim();