From d0e82c10cd98e82100f3efac298d24d4d58ded9e Mon Sep 17 00:00:00 2001 From: Rett Berg Date: Sat, 21 Mar 2020 11:20:23 -0600 Subject: add type to Point.dist and fix error --- typescript.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typescript.html.markdown b/typescript.html.markdown index 640be0cd..f7a41ce1 100644 --- a/typescript.html.markdown +++ b/typescript.html.markdown @@ -114,7 +114,7 @@ class Point { } // Functions - dist() { return Math.sqrt(this.x * this.x + this.y * this.y); } + dist(): number { return Math.sqrt(this.x * this.x + this.y * this.y); } // Static members static origin = new Point(0, 0); @@ -137,9 +137,9 @@ class Point3D extends Point { } // Overwrite - dist() { + dist(): number { let d = super.dist(); - return Math.sqrt(d() * d() + this.z * this.z); + return Math.sqrt(d * d + this.z * this.z); } } -- cgit v1.2.3