class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
Point.distanceTo = function distanceTo(p1, p2) {
let d1 = Math.pow(p1.x - p2.x, 2);
let d2 = Math.pow(p1.y - p2.y, 2);
return Math.sqrt(d1 + d2);
}
let p1 = new Point(1, 2);
let p2 = new Point(2, 3);
let distance = Point.distanceTo(p1, p2);
//distance is 1.4142
console.log(`distance is ${distance}`);