Created
August 17, 2020 06:25
-
-
Save intrnl/a28fd009ec66055f9c3e8bf11f9c2eed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function count (str: string, search: string) { | |
| let n = -1; | |
| let i = 0; | |
| while (i !== -1) { | |
| i = str.indexOf(search, i + 1); | |
| n++; | |
| } | |
| return n; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment