diff --git a/Task1.js b/Task1.js new file mode 100644 index 0000000..13014e6 --- /dev/null +++ b/Task1.js @@ -0,0 +1,30 @@ +function GroupByKey(array,key) +{ + const tempData = {}; + + for ( var index=0; index{ + if(!accumulator[currentvalue[key]]){ + accumulator[currentvalue[key]]=[] + } + accumulator[currentvalue[key]].push(currentvalue) + tempobj=accumulator + return accumulator + },{}); + return tempobj + +} + +console.log(GroupByKey(array,key))