Remove all multiple spaces in Javascript and replace with single space

Viewed 135247

How can I automatically replace all instances of multiple spaces, with a single space, in Javascript?

I've tried chaining some s.replace but this doesn't seem optimal.

I'm using jQuery as well, in case it's a builtin functionality.

4 Answers
Related