i want to count maximum duplicate value from array and number corresponding to it. like if i have array:- var arr=[2,1,4,3,2,8,2,9,2];
i want to display that 4 is repeating maximum time.
Thanks in advance.
You could do it e.g. with this code:
max = 0;
$.each(arr, function(){
current_max = 0;
current = this;
$.each(arr, function(index, value){
if(current==value){
current_max += 1;
}
});
if (current_max > max){
max = current_max;
}
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments