Please help on connect the dots project

I’m working on a connect the dots line game in javascript and html. The program must remember where the beginning and end dots are.

It must only allow a new dot to be added if it connects to either the beginning or end dot.

The beginning and end dots are constantly being updated as new dots are added, ie, if I connect dot x to the end dot, dot x will now become the end dot. I am using the following code to establish whether or not a newly selected dot connects to the existing beginning or end dot.

if((data.clickedDot.x != data.beginning.x)||(data.clickedDot.y != data.beginning.y)&&(data.clickedDot.x != data.end.x)||(data.clickedDot.y != data.end.y))

The problem is that although the new dot is connecting to an existing end or beginning dot, the algorithm returns that it isn’t.

The full code is posted here https://pastebin.com/VqxWQZeh

I thank you all for your help

For further clarification: If the program has successfully confirmed that dot x connects to the end dot or beginning dot, it will return an alert of “you got this” along with the x and y coordinates of the end or beginning dot. If it has not detected a connection to either the end or beginning dots, it will return an alert with he value [true] followed by the xy coordinates of the selected dot

I figured it out. Ask me and I’ll post the solution.