how to get rid of all unneccesracy spaces in a string javascript code example
Example: js method string remove extra spaces
const sentence = ' My string with a lot of Whitespace. '.replace(/\s+/g, ' ').trim()
// 'My string with a lot of Whitespace.'