MCPcopy Create free account
hub / github.com/TheAlgorithms/JavaScript / Pyramid

Class Pyramid

Geometry/Pyramid.js:8–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6 * @param {number} height - The height of the pyramid
7 */
8export default class Pyramid {
9 constructor(bsl, height) {
10 this.bsl = bsl
11 this.height = height
12 }
13
14 baseArea = () => {
15 return Math.pow(this.bsl, 2)
16 }
17
18 volume = () => {
19 return (this.baseArea() * this.height) / 3
20 }
21
22 surfaceArea = () => {
23 return (
24 this.baseArea() +
25 ((this.bsl * 4) / 2) *
26 Math.sqrt(Math.pow(this.bsl / 2, 2) + Math.pow(this.height, 2))
27 )
28 }
29}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected