I have the following objects:
const circle = { center: { x: 0, y: 0 }, radius: 10 };
const point = { x: 0, y: 0 };
And I need to determine whether point lies in a circle. My code is:
function isInsideCircle(circle, point) {
if (((point.x - circle.center.x) * (point.x - circle.center.x) + (point.y - circle.center.y) * (point.y - circle.center.y)) <= circle.radius * circle.radius) return true;
return false;
}
But this does not work at all. The testing environment says, that it returns wrong boolean, so I suppose it doesn't calculate at all. Am I accessing objects properties wrongly?