Finding length, width and height of the sheet required to cover some area using JavaScript

JavascriptWeb DevelopmentFront End Technology

Problem

We are required to write a JavaScript function that takes in the length, height and width of a room.

Our function should calculate the number of sheets required to cover the whole room given that the width of one single sheet is .52 units and length is 10 units.

For the sake of convenience, we should return the number of rolls such that the length is 15% more than the required length.

Example

Following is the code −

 Live Demo

const findSheet = (length, width, height) => {
   if(length === 0 || width === 0){
      return 0;
   }
   const roomArea = 2 * (length + width) * height;
   const rollArea = 0.52 * 10;
   const required = Math.ceil(roomArea / rollArea * 1.15);
   return required;
};
console.log(findSheet(4, 3.5, 3));

Output

10
raja
Updated on 17-Apr-2021 13:10:53

Advertisements