countSubstrings
Counts the occurrences of a substring in a given string.
- Use
Array.prototype.indexOf()to look forsearchValueinstr. - Increment a counter if the value is found and update the index,
i. - Use a
whileloop that will return as soon as the value returned fromArray.prototype.indexOf()is-1.