Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
* 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