let clicksCount = 0;
let firstCoordinates;
let secondCoordinates;
function clickHandler(event) {
clicksCount++;
const coordinates = { x: event.pageX, y: event.pageY };
switch (clicksCount) {
case 1:
firstCoordinates = coordinates;
break;
case 2:
secondCoordinates = coordinates;
break;
default:
window.removeEventListener('click', clickHandler);
}
};
window.addEventListener('click', clickHandler);