Last active
September 10, 2022 03:39
-
-
Save evlymn/183613ef9d7792eedac444341665873c to your computer and use it in GitHub Desktop.
Clean String and Hash Code Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cleanString = (str: string) => str.replace(/[^\w ]/g, '').replace(/\s/g, ''); | |
hash = (str: string) => str.split('').reduce((prev, curr) => (((prev << 5) - prev) + curr.charCodeAt(0)) | 0, 0); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment