Skip to content

Instantly share code, notes, and snippets.

@JonCatmull
Created December 19, 2014 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonCatmull/3d7169797fb9581f0302 to your computer and use it in GitHub Desktop.
Save JonCatmull/3d7169797fb9581f0302 to your computer and use it in GitHub Desktop.
Get distance between to points in JavaScript
function distance(x1,y1,x2,y2) {
return Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1,y2),2));
}
@sbarisic
Copy link

Math.pow((y1, y2), 2)

You meant to put a minus there, not comma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment