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