Day 4: Create a Rectangle Object (Hackerrank problem)

Objective

In this challenge, we practice creating objects. Create a object with given length, width, perimeter, area.

Task

Complete the function in the editor. It has two parameters:  a and b. It must return an object modeling a rectangle that has the following properties:

  • length : equal to a .
  • width : equal to b.
  • perimeter : equal to 2*(a+b)
  • area: equal to a*b
function Rectangle(a, b) {
    return {
        length: a,
        width: b,
        perimeter: 2* (a+b),
        area: a*b,
    }
}

You May Also Like

About the Author: Sunil Yadav

Hi, This is Sunil Yadav, I am full stack dev. I have a passion for learning and sharing my knowledge with others as publicly as possible.

Leave a Reply

Your email address will not be published.