I have an array of people. I want to get the counts of the entire list grouped by each Level and Gender combination. I want to store these results in separate variables that I can display whenever I want in any order.
For instance, get the count for Level B Males and store that in a variable, Level B Females and store that in a variable, and Level B Nonbinary, Level A Males, Level A Females, and Level A Nonbinary, and so on through other levels storing those in their own variables. If storing them in an array is better (and it probably is), the order stored should be Level A Male, Female, Binary down to level Z Male, Female, Binary.
Also, I would like the totals of each Level as well.
I wrote up some stuff in the jsfiddle using a filter, but I've only done Level A. It will be too many lines of code doing Level B, C, D, etc. I think it can be much shorter and cleaner using a loop or something. Can anyone help me find a more efficient method? http://jsfiddle.net/cM94j/2/
var list ={"PEOPLE": [
{ "name": "Bob", "level": "A", "gender": "F"},
{ "name": "Sue", "level": "B", "gender": "F"},
{ "name": "Molly", "level": "A", "gender": "M"},
{ "name": "Joe", "level": "B", "gender": "N"},
{ "name": "Jack", "level": "B", "gender": "F"}
]};
Also, at most this list will have ~80 people and Levels A-H. Going off tangent, with those specs, would I be better off putting this data into a spreadsheet of some kind like excel. It's not a big enough project for a database. How would I output to a website if I do go that route? Should I be outputting these server-side instead of using jQuery?