Answers for "javascript count instances in string"

4

javascript count instances in string

function countOccurences(string, word) {
   return string.split(word).length - 1;
}
var text="We went down to the stall, then down to the river."; 
var count=countOccurences(text,"down"); // 2
Posted by: Guest on August-01-2019

Code answers related to "javascript count instances in string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language