I've an array which contains the data of users joined in last seven days from current date. e.g.
users=['19 Dec', '21 Dec', '21 Dec']
In this array, three users joined in last 7 days. I'm trying to find the unique occurence with this function.
`
let occurences = users.reduce(function (acc, curr) {
return acc[curr] ? ++acc[curr] : (acc[curr] = 1), acc;
}, {});
`
It's returning the object that contains the following key-pairs: {19 Dec: 1, 21 Dec: 2}
I'm expecting to fill the missing values in the object with 0 and with it's respective date. So, the final O/P will be : {19 Dec: 1, 20 Dec: 0, 21 Dec: 2, 22 Dec: 0, 23 Dec: 0, 24 Dec: 0, 25 Dec: 0}
Can someone please help me out to solve this?
I'm expecting to fill the missing values in the object with 0 and with it's respective date. So, the final O/P will be : {19 Dec: 1, 20 Dec: 0, 21 Dec: 2, 22 Dec: 0, 23 Dec: 0, 24 Dec: 0, 25 Dec: 0}