Javascript String countOf(char)

Description

Javascript String countOf(char)


// Define a function for counting the number of instances of a char in a string
String.prototype.countOf = function(char) {
 return this.split(char).length - 1;
}



PreviousNext

Related