Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

50%
+0 −0
Challenges Make a frequency table (histogram)

JavaScript (Node.js), 38 32 bytes -6 bytes thanks to Shaggy! a=>a.map(v=>d[v]=-~d[v],d={})&&d Try it online! Basically just this but returning the result

posted 2y ago by Moshi‭  ·  edited 2y ago by Moshi‭

Answer
#2: Post edited by user avatar Moshi‭ · 2022-09-12T23:47:34Z (about 2 years ago)
  • # [JavaScript (Node.js)], 38 bytes
  • ```javascript
  • (a,d={})=>(a.map(v=>d[v]=1+d[v]||1),d)
  • ```
  • [Try it online!][TIO-l4rxaxov]
  • Basically just [this](https://codegolf.codidact.com/posts/281368/282836#answer-282836) but returning the result
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-l4rxaxov]: https://tio.run/##RY3BCoMwEETP5iv2mNCtNG21B4k/IjkEY0qLGjHBi/rtaUwphWFneAw7b7Uo186vyZ9Hq7tgRKAKtVh3Jmqq8kFNdBG1bhYp@OmwbeMMNQutHZ0H3znvQEBDsoYjRF0RbggFQhklMfJ0eAKPX6VMirmI5XtMF0lkRYixM9D/a7DmO8FgJdnBbd/lvX3SgyKY5IxVZA8f "JavaScript (Node.js) – Try It Online"
  • # [JavaScript (Node.js)], ~~38~~ 32 bytes
  • *-6 bytes thanks to Shaggy!*
  • ```javascript
  • a=>a.map(v=>d[v]=-~d[v],d={})&&d
  • ```
  • [Try it online!][TIO-l4rxaxov]
  • Basically just [this](https://codegolf.codidact.com/posts/281368/282836#answer-282836) but returning the result
  • [JavaScript (Node.js)]: https://nodejs.org
  • [TIO-l4rxaxov]: https://tio.run/##RY3BCoMwEETP5iv2JAmsUttqDxJ/RHIIxpQWa8QEL2J/PU1SSmHYGR7DzlNu0g7rY3HFbNToNfeSd7J8yYVuvFP9JnjxjoaK7wfLc@UHM1sHbrTOAoeeZH2FEHRGuCDUCE2QwMDTqRK4/SpNUsh1KF9DOgkiWkK0WYH@X4PR3wkGO8kiN9NYTuZOI0XQyRlryeE/ "JavaScript (Node.js) – Try It Online"
#1: Initial revision by user avatar Moshi‭ · 2022-06-24T04:00:09Z (over 2 years ago)
# [JavaScript (Node.js)], 38 bytes

```javascript
(a,d={})=>(a.map(v=>d[v]=1+d[v]||1),d)
```

[Try it online!][TIO-l4rxaxov]

Basically just [this](https://codegolf.codidact.com/posts/281368/282836#answer-282836) but returning the result

[JavaScript (Node.js)]: https://nodejs.org
[TIO-l4rxaxov]: https://tio.run/##RY3BCoMwEETP5iv2mNCtNG21B4k/IjkEY0qLGjHBi/rtaUwphWFneAw7b7Uo186vyZ9Hq7tgRKAKtVh3Jmqq8kFNdBG1bhYp@OmwbeMMNQutHZ0H3znvQEBDsoYjRF0RbggFQhklMfJ0eAKPX6VMirmI5XtMF0lkRYixM9D/a7DmO8FgJdnBbd/lvX3SgyKY5IxVZA8f "JavaScript (Node.js) – Try It Online"