Data Visualization · Exercise 1 of 4Next
Beginner
Which circle is under the pointer?
Two circles overlap on a canvas. Write pick(x, y) so it returns the name of the circle at that point, or null if there is none.
B is drawn after A, so where they overlap the answer is B. A point that is NaN is on nothing.
What Check tests
- A point only inside A gives A
- A point only inside B gives B
- Where they overlap, the later circle wins
- Empty space gives null
- A NaN position gives null
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.