var name = new Array();
var amount = new Array();
name[0]="Peter";
amount[0]="50";
name[1]="John";
amount[1]="10";
name[2]="John";
amount[2]="20";
name[3]="Peter";
amount[3]="20";
name[4]="Mary";
amount[4]="40";
I have something like the above. My question is, how can I create a function to eliminate all the duplicates and sum up the values for each person in the arrays? Below is the results I am looking for.
For example:
Peter 70
John 30
Mary 40
Try the following
Now the object
sumwill have a property for every name innameand the value of the property will be the sum of the amounts which had the that nameTo print it out try the following