Select All Checkboxes

Write the code, see it run, pass the checks.

The problem

  • medium
  • Code

Three checkboxes, "Cheese", "Mushrooms" and "Olives", sit under a "Select all" checkbox. Ticking Select all ticks all three, and unticking it clears them. Select all is ticked only when all three are; when some but not all are, it shows as mixed by setting the checkbox's indeterminate property (React has no prop for it, so use a ref). Show how many are picked, e.g. "2 selected".

Your code must pass

  • Select all ticks every topping
  • Unticking Select all clears them
  • Ticking some makes Select all mixed
  • Ticking all three ticks Select all