Can anyone help me with counting the number of passes and fails for each subject in a JSON object array? Here is an example:
[{"Subject":"Maths","status:"Pass"},{"Subject":"Maths","status:"Pass"},
{"Subject":"Maths","status:"Fail"},{"Subject":"Maths","status:"Fail"},
{"Subject":"English","status:"Pass"},{"Subject":"English","status:"Fail"}]
I am looking to transform this data into an object array that looks like this:
[{"Subject":"Maths","Pass":2,"Fail":2},"Subject":"English","Pass":1,"Fail":1}]
This information will be coming from an API and the subjects may vary. Any suggestions on how to handle this dynamic data?