• + 0 comments

    This is my Solution . I tried to use the reduce() method to sum the element , in this case the numbers in the give array. the method takes a callback function as well as the array itself(optional) for which we call the reduce() , the callback function takes 3 param. (previousValue , currentIndexValue , currentIndex(optional) ) and return the result (a number) . class Polygon{ constructor(lenghts){
    this.lenghts = lenghts; } perimeter(){ return this.lenghts.reduce((total , currentValue)=>{return total + currentValue }) } }