In this HackerRank Day 4: Create a Rectangle Object 10 days of javascript problem solution 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:
  1. length : This value is equal to a.
  2. width : This value is equal to b.
  3. perimeter : This value is equal to 2 * (a + b)
  4. area : This value is equal to a * b

HackerRank Day 4: Create a Rectangle Object problem solution

Problem solution in JavaScript programming.

/*
 * Complete the Rectangle function
 */
function Rectangle(a, b) {
    this.length =a;
    this.width =b;
    this.perimeter = 2*(a+b);
    this.area = a*b;
}