Skip to content

Commit 286853b

Browse files
committed
Fix inaccessible move method
1 parent a919dd6 commit 286853b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

JavaScript/closure-class.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ class Point {
44
constructor(ax, ay) {
55
this.x = ax;
66
this.y = ay;
7+
const move = (dx, dy) => {
8+
this.x += dx;
9+
this.y += dy;
10+
};
711
const clone = () => new Point(this.x, this.y);
812
const toString = () => `(${this.x}, ${this.y})`;
9-
return { clone, toString };
10-
}
11-
12-
move(dx, dy) {
13-
this.x += dx;
14-
this.y += dy;
13+
return { move, clone, toString };
1514
}
1615
}
1716

0 commit comments

Comments
 (0)