Javascript to Group Array of Object into combination of two values : <pre><code>var data=[
{custType:1,code:'savings',efDate:'2/3/19',exDate'2/3/19'},
{custType:1,code:'savings',efDate:'2/3/19',exDate:'2/3/19'},
{custType:1,code:'savings',efDate:'2/3/19',exDate:'2/3/19'},
{custType:1,code:'current',efDate:'2/3/19',exDate:'2/3/19'},
{custType:2,code:'current',efDate:'2/3/19',exDate:'2/3/19'},
{custType:2,code:'savings',efDate:'2/3/19',exDate:'2/3/19'},
{custType:2,code:'savings',efDate:'2/3/19',exDate:'2/3/19'}
];
</code></pre>

<p>expected results</p>

<pre><code>var modifiedData=[
    [
    savings=[ {custType:1,code:'savings',efDate:'2/3/19',exDate:'2/3/19'},
              {custType:1,code:'savings',efDate:'2/3/19',exDate:'2/3/19'},
              {custType:1,code:'savings',efDate:'2/3/19',exDate:'2/3/19'}
 ],
    current=[ {custType:1,code:'current',efDate:'2/3/19',exDate:'2/3/19'} ]
    ],
  [
    savings=[ {custType:2,code:'savings',efDate:'2/3/19',exDate:'2/3/19'},
              {custType:2,code:'savings',efDate:'2/3/19',exDate:'2/3/19'} ],
    current=[ {custType:2,code:'current',efDate:'2/3/19',exDate:'2/3/19'} ]
    ]

];
</code></pre>

<p>as i am trying to find a group with (custType and code), i am not able to generate the expected result. Which method i should use here? can i use reduce or groupBy. I am confused about it.</p>
