Demo For: JavaScript: Count Occurrences Of String In String Examples

The string that needs to be searched in is: "This is a string.". So this is our Haystack.

We want to search fo the word "is". So this is our Needle.

You should see an alert as soon as the page loads.