Quantcast
Channel: How to count string occurrence in string? - Stack Overflow
Viewing all articles
Browse latest Browse all 43

Answer by Brandon Frohbieter for How to count string occurrence in string?

$
0
0

function countInstances(string, word) {   return string.split(word).length - 1;}console.log(countInstances("This is a string", "is"))

Viewing all articles
Browse latest Browse all 43

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>