I like your javascript trim function. I have seen a number of similar code using regular expressions and tried some of them. They all work but yours is another refreshing take on ‘trim’.
That’s the beauty of programming – so many ways to solve one problem.