code: function findClosestPointIndexWithinRadius(points, x, y, radiusThreshold) {
      let closestIdx;
      let closestDist = Number.MAX_VALUE;
      points.forEach((d, idx) => {
        let distSqrd = Math.pow(d.x - x, 2) + Math.pow(d.y - y, 2); // changeto: (d.x - x)**2 + (d.y - y)**2;
        if (distSqrd < closestDist && distSqrd < radiusThreshold) {
          closestIdx = idx;
          closestDist = distSqrd;
        }
      });
      return closestIdx;
    }
docs: Find the index of the closest coordinate to a
  reference coordinate in an array of coordinates.
  If no point is found within the threshold distance
  undefined is returned.