Problem
We are required to write a JavaScript function that takes in the length, width and height of a cuboid and return the length of its diagonal.
Example
Following is the code −
const height = 10; const width = 12; const length = 15; const findDiagonal = (l, w, h) => { const ll = l * 2; const ww = w * 2; const hh = h * 2; const sum = ll + ww + hh; const diagonal = Math.sqrt(sum); return diagonal; }; console.log(findDiagonal(length, width, height));
Output
8.602325267042627