Multiple consecutive spaces are causing me a headache in my JS script. I tried doing this:
const originalStr = 'Hello there how are you'
const actual = originalStr.replace(/ /g, ' ')
const expected = 'Hello there how are you'
console.log(`originalStr = '${originalStr}'`)
console.log(`actual = '${actual}'`)
console.log(`expected = '${expected}'`)
console.log(`actual === expected ...`, actual === expected)
But as you can see it's not working. It's failing when there are 3 or more consecutive spaces. Is there a simple way to ensure that there are no consecutive spaces?