Store the frequency of the current array element let curr_c = count ( & arr [ j ] , & arr [ n ] , arr [ j ] ) ;
let curr_c = 0 ; arr . slice ( j , n ) . forEach ( ( item ) => { if ( item == arr [ j ] ) { curr_c ++ } } )