yandex
loader

please wait

  • Ayushi Jain Mar-11-2019 07:32:12 AM ( 2 months ago )

    How to group by based on two json key which is f and b My json array

    var json=[
        {   s:'s',  f:1,  b:1,  q:2   },
        {   s:'s',  f:1,  b:1,  q:3   },
        {   s:'s',  f:2,  b:1,  q:2   },
        {   s:'s',  f:2,  b:1,  q:2   },
        {   s:'s',  f:1,  b:2,  q:2   },
        {   s:'s',  f:1,  b:2,  q:2   },
        {   s:'s',  f:0,  b:1,  q:2   },
        {   s:'s',  f:0,  b:1,  q:2   },
        {   s:'s',  f:1,  b:0,  q:2    },
        {   s:'s',  f:1,  b:0, q:2    },
        {   s:'s',  f:0,  b:0,  q:2    },
        {   s:'s',  f:0,  b:0, q:2    },

    ];

    Expected Output

     var op=[
        {   s:'s',  f:1,  b:1,  q:5   },
        {   s:'s',  f:2,  b:1,  q:4   },
        {   s:'s',  f:1,  b:2,  q:4   },
        {   s:'s',  f:0,  b:1,  q:4   },
        {   s:'s',  f:1,  b:0,  q:4   },
        {   s:'s',  f:0,  b:0,  q:4   },

    ];
     

Please login

Similar Discussion

Recommended For You