Help needed with grouping JavaScript objects by age. Below is my JSON data:
var jsonObj=[{"name":"john","age":23},{"name":"mark","age":25},{"name":"jeni","age":21}]`
I am looking for a grouped result similar to this format.
[23:{"name":"john","age":23},25:{"name":"mark","age":25},21:{"name":"jeni","age":21}]
I have attempted using map
and filter
, but unable to achieve the desired output. Any assistance would be greatly appreciated.