Problem
The trim() method removes whitespace from both sides of a string.
Source
Solution
You can use a Javascript replace method to remove white space like
"hello world".replace(/\s/g, "");
Example
var out = "hello world".replace(/\s/g, "");
console.log(out);