Open this example in the interactive library
Live preview
Source code
// components/ReorderShortfallTotal.tsx
export default function ReorderShortfallTotal({
counts = [12, 0, 5, 18],
target = 10,
}: { counts?: number[]; target?: number } = {}) {
return (
<output>
{counts.reduce((n, v) => n + Math.max(0, target - v), 0)} units to reorder
</output>
);
}
