A recommendation needs a scoring rule that readers can understand. An equal score or an empty candidate list requires an intentional fallback.
Worked example
// app/parks/page.tsx
export default function EasiestParkRecommendation() {
const parks = [
{ name: "Cedar", km: 2.4, features: ["shade", "water"], grade: 1 },
{ name: "Ridge", km: 6.1, features: ["views"], grade: 3 },
{ name: "Lake", km: 3.5, features: ["water", "views"], grade: 2 },
];
const p = [...parks].sort((a, b) => a.grade - b.grade || a.km - b.km)[0];
return (
<section>
<h1>Gentle trail</h1>
<p>
{p.name} · grade {p.grade} · {p.km} km
</p>
</section>
);
}Implementation notes
Difficulty alone may not reflect accessibility, distance or seasonal availability. State the scoring criterion next to the recommendation.
Try it yourself
Compare two parks with identical difficulty and a filter that removes every park.
Open the Next.js example →Editorial date July 20, 2025 · Published December 6, 2026