If you want to format a string and remove all whitespace, like passing from 'Hello my name is Olive' to 'HelloMyNameIsOlive' there is a simple function for that :

const deleteSpaceString = (string: string) => string.replace(/\s+/g, '')

This function for deleting all whitespace can be useful for formatting document path to avoid any error. From var/user/me/my document saved like this.doc to var/user/me/my documentsavedlikethis.doc

Or creating id from name of city : San Francisco to SanFrancisco