Finding Length, Width, and Height of Sheet Using JavaScript



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
Updated on: 2021-04-17T13:10:53+05:30

252 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements