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
- LCP p75 is 2600
- INP p75 is 180 and CLS p75 is 0.27
- LCP is rated
needs-improvement - INP is
goodand CLS ispoor - 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.