text: Maximum occurrence of prefix in the Array | Function to return the count of the required prefix ; Find the frequency of first character of string ; Driver code
code: function prefixOccurrences ( str ) { var c = str . charAt ( 0 ) ; var countc = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str . charAt ( i ) == c ) countc ++ ; } return countc ; } var str = " " ; document . write ( prefixOccurrences ( str ) ) ;