Finding 2D convex hull using Graham scan in Javascript