CodeOath
← All posts
JavaScript60 min total · 16 parts

JavaScript Array and Object Methods Cheat Sheet

Part 15 of 16 · ~1 min

Putting It Together: One Pipeline End to End

Diagram showing the candidates array narrowed by .filter(), then reshaped by .map() into a short scored shortlist

const shortlist = candidates
  .filter(c => c.status === "active" && c.role === "backend" && c.score >= 75)
  .map(c => ({ name: c.name, score: c.score }));
// [{ name: "Priya Shah", score: 82 }, { name: "Amara Chen", score: 91 }]

const byId = Object.fromEntries(candidates.map(c => [c.id, c]));
// a full lookup table by id, built in one line

const averageScore = candidates.reduce((sum, c) => sum + c.score, 0) / candidates.length;
// 74.8

const shortlistLine = shortlist.map(c => c.name).join(" and ");
// "Priya Shah and Amara Chen" — a one-line summary, ready for a notification

Filter, then map — that chain reads almost like the plain-English sentence describing it: active backend candidates scoring at least 75, boiled down to just their names and scores. Add a lookup table built from Object.fromEntries() and a .join() for turning a short list back into a sentence, and that's a small set of patterns that quietly covers most of the day-to-day data-shaping work you'll actually write.