js version of our triangluation paring fun