SyntaxFix
Write A Post
Hire A Developer
Questions
Note that Math.hypot is part of the ES2015 standard. There's also a good polyfill on the MDN doc for this feature.
Math.hypot
So getting the distance becomes as easy as Math.hypot(x2-x1, y2-y1).
Math.hypot(x2-x1, y2-y1)