jsGirl
01-13-2008, 07:18 PM
Hello, Maybe this question isnt directly related to DOM but I will eventually need to do some dom scripting after I am successful with this array.
I have an array:
arrNums = [122379, 198702, 102884, 109231];
now this arrNums resets itself for every post on the page and there might be repeating numbers. I need to write a 2d array myArray['num'] storing numbers and myArray['count'] storing count of each time the number has occured.
arrNums = 122379, 198702, 102884, 109231;
for (i=0; i<arrNums.length; i++){
(j=0; j<myArray['num'].length; j++){
if (myArray['num'][j] == arrNums[i]) { // if this number already exists then increment count}
else {myArray['num'][i] = arrNums[i]; // else set the new number
}
I know I am doing it completely wrong but i desperately need help! :
I have an array:
arrNums = [122379, 198702, 102884, 109231];
now this arrNums resets itself for every post on the page and there might be repeating numbers. I need to write a 2d array myArray['num'] storing numbers and myArray['count'] storing count of each time the number has occured.
arrNums = 122379, 198702, 102884, 109231;
for (i=0; i<arrNums.length; i++){
(j=0; j<myArray['num'].length; j++){
if (myArray['num'][j] == arrNums[i]) { // if this number already exists then increment count}
else {myArray['num'][i] = arrNums[i]; // else set the new number
}
I know I am doing it completely wrong but i desperately need help! :