Remove spaces from a string
JavaScript version
const removeSpaces = (str) => str.replace(/\s/g, '');
TypeScript version
const removeSpaces = (str: string): string => str.replace(/\s/g, '');
Examples
removeSpaces('hel lo wor ld'); // 'helloworld'
JavaScript version
const removeSpaces = (str) => str.replace(/\s/g, '');
TypeScript version
const removeSpaces = (str: string): string => str.replace(/\s/g, '');
Examples
removeSpaces('hel lo wor ld'); // 'helloworld'