You forgot to wrap absolute value around the subtractions. sqrt of a negative number is NaN.
EDIT: I am dumb. You probably meant to do euclidean distance, which is sqrt((x2-x1)^2+(y2-y1)^2), squared instead of abs.
(If you meant to do taxicab distance, aka distance if you can only move horizontally and vertically, that's abs(x2-x1)+abs(y2-y1).)