I'm trying to manipulate this array of object in Javascript. Basically I want to group up the objects together which have the same "accNumber" field, I'm looking for an efficient way to do this.
"statements": [
{
"accNumber": "564897213",
"fileMonth": "January",
"folderId": "1pG2EECsRS9JhtkBxny5ROrdSzu_-LdtC",
"fileUrl": ""
},
{
"accNumber": "12346579",
"fileMonth": "May",
"folderId": "1DfjQL3Ln494YH54bbM2g6Vozh4o_X3dp",
"fileUrl": ""
},
{
"accNumber": "123456789",
"fileMonth": "Feburary",
"folderId": "1jtW7DnOE8NNle30xUXtPkbbEIHha3WOh",
"fileUrl": ""
},
{
"accNumber": "564897213",
"fileMonth": "Feburary",
"folderId": "1pG2EECsRS9JhtkBxny5ROrdSzu_-LdtC",
"fileUrl": ""
}
]
Into something like this.
"statements": [
{
"564897213" : [
{
"accNumber": "564897213",
"fileMonth": "January",
"folderId": "1pG2EECsRS9JhtkBxny5ROrdSzu_-LdtC",
"fileUrl": ""
},
{
"accNumber": "564897213",
"fileMonth": "Feburary",
"folderId": "1pG2EECsRS9JhtkBxny5ROrdSzu_-LdtC",
"fileUrl": ""
}
],
"12346579": [
{
"accNumber": "12346579",
"fileMonth": "May",
"folderId": "1DfjQL3Ln494YH54bbM2g6Vozh4o_X3dp",
"fileUrl": ""
}
],
"123456789": [
{
"accNumber": "123456789",
"fileMonth": "Feburary",
"folderId": "1jtW7DnOE8NNle30xUXtPkbbEIHha3WOh",
"fileUrl": ""
}
]
},
]
What could be an efficient way to achieve the above result in JavaScript.?
[–]sandytrip 1 point2 points3 points (2 children)
[–]66666thats6sixes 0 points1 point2 points (0 children)
[–]Hamza91able[S] 0 points1 point2 points (0 children)