Skip to content

Commit e522d81

Browse files
authored
Create Classes.js
1 parent 84924e2 commit e522d81

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Implement a Polygon class with the following properties:
3+
* 1. A constructor that takes an array of integer side lengths.
4+
* 2. A 'perimeter' method that returns the sum of the Polygon's side lengths.
5+
*/
6+
class Polygon{
7+
constructor(sides){
8+
this.sides=sides
9+
}
10+
perimeter(){
11+
return this.sides.reduce(function add(a,b){ return a+b;})
12+
}
13+
}

0 commit comments

Comments
 (0)