I have written an expression to get the distance between two points, but it does not work and I haven't a clue why. It's pretty simple:
function findDistance(xa, xb, ya, yb)
{
return Math.sqrt( (xa - xb)^2 + (ya - yb)^2 );
}
findDistance(682, 617, 310, 342);
The error I get is, "Error at line 0... invalid numeric result (divide by zero?)."
I am so confused by this. It seems so straight forward, so I am not even sure what to ask. Can anyone see what is wrong with this?
EDIT: I am trying to narrow down the issue. Even using the following expression is not working:
Math.sqrt( (682-617)^2 + (310-342)^2 );
Narrowing down further, this finally worked:
Math.sqrt( 5249 );
I also isolated and confirmed that X^2 is the correct way to square something, so what gives?