Sort by

recency

|

277 Discussions

|

  • + 0 comments
    class Polygon {
      constructor(length) {
        this.length = length;
      }
    
      perimeter() {
        let sum = 0;
        for (let i = 0; i < this.length.length; i++) {
         sum += this.length[i];
        }
    		
    		
        return sum;
      }
    }
    
  • + 0 comments

    "Singleton Class Using a Function" has incorrect information in the "Topics".

    The given example creates an object, similarly as if one would do:

    myObject = {a:1};

    It doesn't create a singleton.

  • + 0 comments
    class Polygon {
        constructor(sides) {
            this.sides = sides
        }
        perimeter() {
            let sides = this.sides
          return sides.reduce((side, accum) => accum += side, 0)
        }
    }
    
  • + 0 comments
    class Polygon {
            constructor(_sides) {
                this.sides = _sides;
            }
            perimeter(){
                var perimeter = 0;
                this.sides.forEach(side => perimeter += side);
                return perimeter;
            }
        }
    
  • + 0 comments
    class Polygon {
        constructor(side) {
            this.side = side;
        }
        perimeter() {
            let side=this.side
            return side.reduce((a,b)=> a+b)
        }
    }