Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 402 Bytes

removeWhitespace.md

File metadata and controls

16 lines (12 loc) · 402 Bytes
title tags
removeWhitespace
string,regexp,beginner

Returns a string with whitespaces removed.

  • Use 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.'