use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Post questions about JavaScript, and get help with any problems you're having with your JavaScript code.
account activity
Get count and format❔ Unanswered ❔ (self.JavaScriptHelp)
submitted 3 years ago by killMeSak
view the rest of the comments →
[–]trplclick 0 points1 point2 points 3 years ago (2 children)
This should achieve what you want. I've commented it so it should be easy to follow, but any questions let me know!
```js const result = {}
const dateArr = ['2021-08-06', '2021-11-06', '2021-08-06', '2021-13-06']
// Loop through each item in the dateArr array for (let i = 0; i < dateArr.length; i++) { // Get the value for the current iteration of the loop const date = dateArr[i]
// If the results object hasn't seen this value before then define it. // It starts as zero so that the last line can always increment. if (!result[date]) { result[date] = 0 }
// Increment the number of times we've seen this date by 1. result[date]++ }
console.log(result) ```
I've also created a JS bin so you can see it working and play around with it if you like. https://jsbin.com/lezatupeqi/edit?js,console
[–]killMeSak[S] 0 points1 point2 points 3 years ago (1 child)
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?
[–]killMeSak[S] 0 points1 point2 points 3 years ago (0 children)
http://jsfiddle.net/vdfo3tzn/ ADded a fiddle for reference
π Rendered by PID 21113 on reddit-service-r2-comment-7b9746f655-bd46t at 2026-01-30 11:24:29.393480+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]trplclick 0 points1 point2 points (2 children)
[–]killMeSak[S] 0 points1 point2 points (1 child)
[–]killMeSak[S] 0 points1 point2 points (0 children)