Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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