String.prototype.replace()
with a regular expression to replace all occurrences of whitespace characters with an empty string.const removeWhitespace = str => str.replace(/\s+/g, '');
removeWhitespace('Lorem ipsum.\n Dolor sit amet. '); // 'Loremipsum.Dolorsitamet.'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️