Command Palette

Search for a command to run...

Hectal
Phase 23: Build, Deploy and Run in Production
React · Exercise 3 of 5 PreviousNext
Intermediate

Rate Core Web Vitals at the 75th percentile

You have eight field samples for each metric. Finish two functions:

- p75(values): sort the values from small to large and return the one at position Math.ceil(0.75 * n) counting from 1 (the nearest-rank 75th percentile);

- rate(name, value): return "good", "needs-improvement" or "poor" using the official thresholds (LCP 2500/4000 ms, INP 200/500 ms, CLS 0.1/0.25; a value equal to a boundary belongs to the better group).

Each metric has a row <tr id="LCP"> (and INP, CLS) with a cell .p75 and a cell .rating. Keep that markup.

What Check tests

  1. LCP p75 is 2600
  2. INP p75 is 180 and CLS p75 is 0.27
  3. LCP is rated needs-improvement
  4. INP is good and CLS is poor
  5. The original samples are not changed

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.