Count substrings in string
var theString = "This is a string."; console.log(theString.split("is").length - 1);