Skip to content

Instantly share code, notes, and snippets.

@Neptune998
Created August 9, 2020 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neptune998/778a4ecc8d9265ad0e813a55a44534a4 to your computer and use it in GitHub Desktop.
Save Neptune998/778a4ecc8d9265ad0e813a55a44534a4 to your computer and use it in GitHub Desktop.
/*
* 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