The span of a range differs from the count of discrete values inside it. Define whether endpoints are inclusive before choosing the label.
Worked example
// components/RangeSpanReadout.tsx
export default function RangeSpanReadout({
values = [2, 3, 3, 6, 11],
}: { values?: number[] } = {}) {
return (
<output>
{values.length
? "Span: " + (Math.max(...values) - Math.min(...values))
: "No observations"}
</output>
);
}Implementation notes
A reversed range can mean invalid input or a deliberate descending sequence. Do not silently take an absolute difference unless that is the intended contract.
Try it yourself
Try equal endpoints and a range whose upper limit is lower than its start.
Open the React example →Editorial date June 25, 2026 · Published December 6, 2026