Intermediate
The nearest station, with a reach
Build a quadtree of three stations and set window.nearest(x, y, reach).
It returns the name of the nearest station within reach, or null when there is none (too far, or a NaN position).
What Check tests
- Near Quay gives Quay
- Near Chapel gives Chapel
- Too far from every station gives null
- A NaN position gives null
- A huge reach still finds the nearest
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.