Answers for "javascript program counting the number of words starting with "a""

4

javascript count occurrences 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"

Browse Popular Code Answers by Language