I'm currently facing a challenge in JavaScript where I need to generate arrays based on the values of another array.
For instance, I have an array of dates in string format (dates) listed below:
["30/09/2015", "31/10/2015", "30/11/2015", "31/12/2015"]
Additionally, I have an Object that represents various bank accounts (balancesSortByAccId) as shown:
Cash - (Array size: 3)
id: 1, date: "30/09/2015", balance: 30
id: 2, date: "31/10/2015", balance: 50
id: 3, date: "30/11/2015", balance: 100
Natwest - (Array size: 2)
id: 4, date: "30/11/2015", balance: 400
id: 5, date: "31/12/2015", balance: 200
My goal is to create arrays for each date in the 'dates' array by retrieving balances from the accounts in 'balancesSortByAccId'. Here's what I aim to achieve:
[30, 50, 100, null]
[null, null, 400, 200]
If you have any suggestions on how I could accomplish this, please let me know!
UPDATE: You can view my jsfiddle code here - https://jsfiddle.net/gx8bLehb/