New:Embedded & IoT Bootcamp
Exercise Difficulty: IntermediateLanguage: JavaScriptDuration: 30 min

Array Methods Workout

Five practical tasks that drill map, filter, reduce, sort and flatMap against realistic data.

Abhishek Sharma 2026-08-11 Programming / JavaScript
Problem statement Intermediate JavaScript 30 min

Given an array of order objects, use map, filter, reduce, sort and flatMap to answer five business questions without mutating the source data.

Requirements

  • Return only shipped orders
  • Compute revenue per customer
  • Find the highest-value order without mutating the input
  • Group orders by status and flatten all line items

Need a reference?

Refresh the concepts before attempting the challenge on your own.

MDN: Array reference

Compare with the solution

Finish your attempt first, then open the reference solution to compare trade-offs.

Study the worked array patterns

Tasks

  1. Return only shipped orders.
  2. Compute revenue for each customer.
  3. Find the highest-value order without mutating the source array.
  4. Group orders by status.
  5. Produce a flat list of line items across all orders.

Rules

Prefer pure functions. Avoid for loops unless the task explicitly benefits from early exit.

Want more like this?

Browse the full exercises library, organised by topic.

All exercises

Related learning

Tutorial2026-06-09

Data Types

Deep dive into JavaScript data types: numbers, strings, arrays, and array methods

Programming / JavaScript

JavaScriptData Types
Tutorial2026-06-09

An Introduction to JavaScript

Learn what JavaScript is, its history, and how to get started with tools and the developer console

Programming / JavaScript

JavaScriptProgramming
Tutorial2026-06-09

JavaScript Fundamentals

Master the basics: Hello World, code structure, variables, data types, and type conversions

Programming / JavaScript

JavaScriptProgramming