I have 2 arrays with the following data:
Array1 = [A, A, A, A, B, B, B, C, C, C, C, C];
Array2 = [4, 2, 4, 6, 3, 9, 6, 5, 4, 6, 2, 8];
I want to create 2 new arrays from these values:
Array3 = [A, B, C];
Array4 = [4, 6, 5];
The values in Array 4 are the averages from Array2.
How should the javascript or jquery code look like to create Array3 and Array4?
edit:
I would like to group the values like this:
Array1 Array2
A 2
A 4
------------------
B 2
B 6
------------------
C 3
C 6
C 9
result:
Array3 Array4
A 3 Average from 2 and 4
B 4 Avarage from 2 and 6
C 6 Average from 3, 6 and 9
Try