How to calculate the surface area of a pyramid in Node.js

1 Answer

0 votes
function surfaceAreaOfPyramid(sideLength, height) {
    const surfaceArea = (sideLength * sideLength) + 2 * 
                        ( sideLength * Math.sqrt(Math.pow(height, 2) + 
                          Math.pow((sideLength / 2), 2)) );
 
    return surfaceArea;
}
 
const sideLength = 6;
const height = 11;
 
console.log(surfaceAreaOfPyramid(sideLength, height));
 
 
 
/*
run:
 
172.82105101189654
 
*/

 



answered Dec 31, 2024 by avibootz

Related questions

1 answer 128 views
1 answer 123 views
1 answer 168 views
1 answer 178 views
1 answer 120 views
1 answer 123 views
...