Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
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
Comments
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

1 solution

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
 
Share this answer
 

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



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