Create a function / to calculate the distance between two points defined by their x and y coordinates.
We are going to write a function called getDistance will accept four integers (x1, x2, y1, and y2) as arguments.
We are given the coordinates of two points (x1, y1) and (x2, y2). The goal of the function is to return the distance between those two points.
To get the distance of those two points, we use the following formula:
dx is the difference between the x-coordinates of the points while dy is the difference between the-y-coordinates of the points.
Example:
getDistance(100, 100, 400, 300)
// output: 360.5551275463989
In the example above we have point 1: (100, 400) and point 2: (100, 300)
If we get values of x1 and x2 and subtract the differences, we get dx2(제곱). If we do the same with y1 and y2 and subtract the differences, we get yx2(제곱).