How do I get the array-members and the number of times they repeat (recurrences)?
I currently have this script
//COUNT VAL
var curr = '';
var previous = '';
var arr = new Array();
var sorted = count.sort();
for(var c=0; c < sorted.length; c++){
if(sorted[c] != ''){
if(sorted[c] != curr){
var repeat = 1;
arr[sorted[c]] = repeat;
curr = sorted[c];
}
else if(sorted[c] == curr){
repeat++;
}
}
}
alert(JSON.stringify(arr));
The values of the array “count” are (I used JSON.stringify):
[" 2"," 2"," 2","1","1","1","1","1","1","1","1","1","1",null,null,null,null,null,null,null,null,null,null,null,null,null]
What I expect my script to display… (Im expecting it to return an array)
[1: 10, 2: 3]
(x: y) x is the number, y is the number of times it repeated.
What I get…
[null,1,1]
This will give you the summary, ignoring null values