Created
September 11, 2023 08:20
-
-
Save codeperfectplus/61de017bb25273a7084b0fe8b4e42507 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| class Polygon{ | |
| constructor(sides){ | |
| this.sides = sides; | |
| this.perimeter = this.perimeter; | |
| } | |
| perimeter() { | |
| let sum = 0; | |
| for(let i =0;i<this.sides.length;i++) { | |
| sum = sum + this.sides[i]; | |
| } | |
| return sum; | |
| } | |
| } | |
| const triangle = new Polygon([3,4,5]); | |
| console.log(triangle.perimeter()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment