JavaScript version
removeSpaces.js
const removeSpaces = (str) => str.replace(/\s/g, '');
TypeScript version
removeSpaces.ts
const removeSpaces = (str: string): string => str.replace(/\s/g, '');
Examples
examples.js
removeSpaces('hel lo wor ld'); // 'helloworld'