Command Palette

Search for a command to run...

Hectal
Phase 5: Arrays
JavaScript · Exercise 6 of 6 Previous
Intermediate

A sortable, searchable leaderboard

Build a leaderboard from the players array. Each player is a table row in #rows: first cell the name, second cell the score.

Sort by score shows the highest score first; players with the same score go in A-to-Z order. Sort by name shows names A to Z. Before any button is clicked, show players in their original order.

Typing in #search shows only players whose name contains the text, ignoring capital letters, and keeps the current sort.

Never change or reorder the players array itself.

What Check tests

  1. All 5 players show in their original order at first
  2. Sort by score: highest first, ties A to Z
  3. Sort by name: A to Z
  4. Searching "R" shows only Kabir, Meera and Ravi (still sorted by name)
  5. Switching to score keeps the search
  6. Clearing the search shows everyone again
  7. The players array itself was never reordered

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.