freq maintains frequency of each character in word
let freq = new Array ( 27 ) . fill ( 0 ) ; for ( let i = 0 ; i < 27 ; i ++ ) freq [ i ] = 0 ; let vowel = 0 ; let consonant = 0 ; for ( let i = 0 ; i < word . length ; i ++ ) { freq [ word . charCodeAt ( i ) - 65 ] ++ ;