
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find Length of Diagonal of a Cuboid Using JavaScript
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
Advertisements