Created
August 9, 2020 09:08
-
-
Save Neptune998/778a4ecc8d9265ad0e813a55a44534a4 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* Implement a Polygon class with the following properties: | |
* 1. A constructor that takes an array of integer side lengths. | |
* 2. A 'perimeter' method that returns the sum of the Polygon's side lengths. | |
*/ | |
class Polygon { | |
constructor(sides) { | |
this.sides = sides; | |
} | |
perimeter() { | |
return this.sides.reduce((a, b) => a + b);; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment