DeepFrontend
Practice ArenaBlogSign in
Go Pro
DeepFrontend

Interview-grade learning paths and hands-on practice for mid-to-senior engineers. Master internals, patterns, and system architecture with runnable code.

All systems operational

Core Courses

  • -JavaScript Internals
  • -React Reconciliation
  • -TypeScript rigor
  • -Next.js Caching
  • -Node.js Event Loop
  • -System Design
  • -Web Security
  • -CSS & Page Layouts

Explore

  • Learning Paths
  • Practice Arena
  • Pricing Options
  • HTML Sitemap

Resources

  • Privacy Policy
  • Terms of Service
  • Email Support

© 2026 DeepFrontend. All rights reserved.

Expert learning environments for web engineering teams.

← All challenges
warmup8 min

Implement keyBy(arr, keyFn)

Implement keyBy(arr, keyFn)

Like groupBy, but for the common case where each key is expected to be unique — write keyBy(arr, keyFn) that returns an object mapping each key to its single matching item (not an array). If two items share a key, the later one wins.

keyBy([{ id: 1, name: "Ada" }, { id: 2, name: "Grace" }], (u) => u.id);
// { 1: { id: 1, name: "Ada" }, 2: { id: 2, name: "Grace" } }

Run your code to see results.

Stuck? This challenge exercises:

javascript.data-structures