codehs-graphics
Version:
Helpers used to run graphics problems in the CodeHS editor.
18 lines (15 loc) • 395 B
JavaScript
/**
* Get the distance between two points, (x1, y1) and (x2, y2)
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @returns {number} Distance between the two points.
*/
var getDistance = function(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
};
module.exports = {
getDistance: getDistance,
};
;