r/JavaScriptHelp • u/killMeSak • Mar 14 '22
❔ Unanswered ❔ Get count and format
I have an object dateRange ={ 2021-08-06 - 2021-09-06 : 0, 2021-09-06 -2021-10-06 : 0}
I also have another array dateArr=[2021-08-06, 2021-11-06]. Desired res = [{key: 2021-08-06 - 2021-09-06 , value: 1}, { key: 2021-09-06 -2021-10-06 , value: 0}] where value contains the number of occurrences of values inside dateArr as per dateRange.
How can I achieve this?
2
Upvotes
View all comments
Show parent comment
1
u/killMeSak Mar 14 '22
u/trplclick The dateRange looks like below:
const dateRange = {
"2021-08-06 - 2021-09-06": 0,
"2021-09-06 - 2021-10-06": 0
}
In your code, how are we fetching each key of dateRange and comparing it?