Count frequency of unique element
let frequency = new Map ( ) ; for ( let element = 0 ; element < unique . length ; element ++ ) { let freq = 0 ; for ( let i = 0 ; i < unique . length ; i ++ ) { if ( unique [ element ] == unique [ i ] ) { freq ++ ; } } frequency [ element ] = freq ; }