HomeChallengesRepsProblemsLeaderboardTake a challenge

From SQL to JavaScript

Write one function that returns exactly what a GROUP BY query would. No loops.

Intermediate20 min on the clock5 graded checks · 100 pointsJavaScript + TypeScript
Graded by running your code against real cases.

What you build

  • WHERE: only completed orders above 100
  • GROUP BY country
  • Aggregate total_sales and order_count
  • ORDER BY total_sales descending
  • Leave the orders array exactly as you found it

Done means

The same rows, in the same order, as the SQL query would return.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. WHERE — only completed orders above 100+15Array methods
  2. GROUP BY — one row per country+20Array methods
  3. Both aggregates are right+25Array methods
  4. ORDER BY total_sales descending+20Array methods
  5. The orders array comes back untouched+20Not mutating your inputs

What it teaches

The rest of JavaScript + TypeScript