> For the complete documentation index, see [llms.txt](https://kkishan114.gitbook.io/10-days-of-javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kkishan114.gitbook.io/10-days-of-javascript/index/day-4-classes.md).

# Day 4: Classes

### Problem Link <a href="#problem" id="problem"></a>

* [x] [**HackerRank Problem Link**](https://www.hackerrank.com/challenges/js10-class/problem)

### Solution

* [x] **JS Solution**

{% code title="classes.js" %}

```javascript
function Polygon(shape) {
  this.type = shape;
  this.perimeter = getPerimeter;
}

function getPerimeter() {
  return this.type.reduce((a, b) => a + b);
}
```

{% endcode %}
