15,665,276 members
See more:
there are some values in below format

[[A,150,500,6000],[B,160,700,7000],[B,200,633,9000],[B,210,633,9000]]

i need to do group by & do sum

i need final output to be

A,150,500,6000
B,570,1966,2500

the above need to be achieved either with java script or j query

https://forums.asp.net/p/2060010/5940708.aspx?p=True&t=635729744287236348[^]
Posted
Kornfeld Eliyahu Peter 19-Jul-15 6:52am
Sergey Alexandrovich Kryukov 19-Jul-15 13:29pm
This is not really "format", just the sample of something.

If you simply define A and B, you could use it in JavaScript immediately:
var A, B
var array = [[A,150,500,6000],[B,160,700,7000],[B,200,633,9000],[B,210,633,9000]]
// now you can access members directly:
var second = array[1]; // returns [B,160,700,7000]
var element = array[1][1]; // returns first number, 140
Alternatively, you can parse string, and so on, but you can simply use it as the argument of the call to `eval` and do all of the above.
—SA

## Solution 1

If you simply define A and B, you could use it in JavaScript immediately:
JavaScript
```var A, B
var array = [[A,150,500,6000],[B,160,700,7000],[B,200,633,9000],[B,210,633,9000]]
// now you can access members directly:
var second = array[1]; // returns [B,160,700,7000]
var element = array[1][1]; // returns first number, 140```

Alternatively, you can parse string, and so on, but you can simply use it as the argument of the call to `eval` and do all of the above.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 135 Richard Deeming 80 Dave Kreskowiak 70 George Swan 35 CPallini 30
 OriginalGriff 2,433 Graeme_Grant 1,110 Richard Deeming 888 Richard MacCutchan 673 Dave Kreskowiak 601

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900