We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 84924e2 commit e522d81Copy full SHA for e522d81
Hackerrank solutions/10 days of js/Classes.js
@@ -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