Count and Print the alphabets having ASCII value in the range [ l , r ] | Function to count the number of characters whose ascii value is in range [ l , r ] ; Initializing the count to 0 ; Increment the count if the value is less ; return the count ; Driver code
function CountCharacters ( str , l , r ) { let cnt = 0 ; let len = str . length ; for ( let i = 0 ; i < len ; i ++ ) { if ( l <= str [ i ] . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= r ) { cnt ++ ; document . write ( str [ i ] + " " ) ; } } return cnt ; } let str = " " ; let l = 102 , r = 111 ; document . write ( " " + " " ) ; document . write ( " " + CountCharacters ( str , l , r ) ) ;