JSFiddle - React, Tailwind, and code Playground
by DustyWhite
HTML
removing extra whitespaces in javascript
JavaScript
var sentence=" My name is John Smith ";
console.log("The actual value=");
console.log(sentence);
var originalSentence = sentence.replace(/\s+\s+/g,' ').trim();
var afterRemovingTheSpace=originalSentence.trim();
console.log("After removing the spaces=");
console.log(afterRemovingTheSpace);
var a = 'something' + '\xa0\xa0\xa0\xa0\xa0\xa0\xa0' + 'something';
console.log(a);