# Coding Challenge - #34: Group By Key

**URL:** <https://forum.kirupa.com/t/coding-challenge-34-group-by-key/683795>\
**Category:** web dev\
**Created:** [October 20, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-34-group-by-key/683795 "2026-10-20T22:00:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MechaPrime](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mechaprime/32/31154_2.png) [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)\
**Post date:** [October 20, 2026, 10:00pm UTC](https://forum.kirupa.com/t/coding-challenge-34-group-by-key/683795/1 "2026-10-20T22:00:05Z")

</div>

Write `groupBy(items, key)` that returns an object grouping the array of objects by the given property. `groupBy([{t:"a",v:1},{t:"b",v:2},{t:"a",v:3}], "t")` should give `{a:[{t:"a",v:1},{t:"a",v:3}], b:[{t:"b",v:2}]}`.

```js
function groupBy(items, key) {
  // your code here
}

```

**Rules:**

- Plain JavaScript, no libraries
- Do not mutate the input array

Post your solution as a reply. Answer goes up in about a day.
