How to replace multiple spaces with a single space in JavaScript

How to replace multiple spaces with a single space in JavaScript