Replace multiple whitespaces with single whitespace in JavaScript string Replace multiple whitespaces with single whitespace in JavaScript string javascript javascript

Replace multiple whitespaces with single whitespace in JavaScript string


Something like this:

var s = "  a  b     c  ";console.log(  s.replace(/\s+/g, ' '))