1
1
/*
2
- Calculate the volume of the shapes
3
-
4
- Volume for Cuboid
5
- Volume for Cube
6
- Volume for Cone
7
- Volume for Pyramid
8
- Volume for Cylinder
9
- Volume for Triangular Prism
10
- Volume for Pentagonal Prism
11
- Volume for Sphere
12
- Volume for Hemisphere
13
- */
2
+ Calculate the volume of the shapes
3
+
4
+ Volume for Cuboid
5
+ Volume for Cube
6
+ Volume for Cone
7
+ Volume for Pyramid
8
+ Volume for Cylinder
9
+ Volume for Triangular Prism
10
+ Volume for Pentagonal Prism
11
+ Volume for Sphere
12
+ Volume for Hemisphere
13
+ */
14
14
15
15
/*
16
16
Calculate the volume for a Cuboid
@@ -42,7 +42,7 @@ const volCube = (length) => {
42
42
const volCone = ( radius , height ) => {
43
43
isNumber ( radius , 'Radius' )
44
44
isNumber ( height , 'Height' )
45
- return ( Math . PI * radius ** 2 * height / 3.0 )
45
+ return ( Math . PI * radius ** 2 * height / 3.0 )
46
46
}
47
47
48
48
/*
@@ -54,7 +54,7 @@ const volPyramid = (baseLength, baseWidth, height) => {
54
54
isNumber ( baseLength , 'BaseLength' )
55
55
isNumber ( baseWidth , 'BaseWidth' )
56
56
isNumber ( height , 'Height' )
57
- return ( baseLength * baseWidth * height ) / 3.0
57
+ return ( baseLength * baseWidth * height ) / 3.0
58
58
}
59
59
60
60
/*
@@ -71,7 +71,7 @@ const volCylinder = (radius, height) => {
71
71
/*
72
72
Calculate the volume for a Triangular Prism
73
73
Reference: http://lrd.kangan.edu.au/numbers/content/03_volume/04_page.htm
74
- return 1 / 2 * baseLengthTriangle * heightTriangle * height
74
+ return 1 / 2 * baseLengthTriangle * heightTriangle * height
75
75
*/
76
76
const volTriangularPrism = ( baseLengthTriangle , heightTriangle , height ) => {
77
77
isNumber ( baseLengthTriangle , 'BaseLengthTriangle' )
@@ -89,7 +89,7 @@ const volPentagonalPrism = (pentagonalLength, pentagonalBaseLength, height) => {
89
89
isNumber ( pentagonalLength , 'PentagonalLength' )
90
90
isNumber ( pentagonalBaseLength , 'PentagonalBaseLength' )
91
91
isNumber ( height , 'Height' )
92
- return ( 5 / 2 * pentagonalLength * pentagonalBaseLength * height )
92
+ return ( 5 / 2 * pentagonalLength * pentagonalBaseLength * height )
93
93
}
94
94
95
95
/*
@@ -99,7 +99,7 @@ const volPentagonalPrism = (pentagonalLength, pentagonalBaseLength, height) => {
99
99
*/
100
100
const volSphere = ( radius ) => {
101
101
isNumber ( radius , 'Radius' )
102
- return ( 4 / 3 * Math . PI * radius ** 3 )
102
+ return ( 4 / 3 * Math . PI * radius ** 3 )
103
103
}
104
104
105
105
/*
@@ -109,7 +109,7 @@ const volSphere = (radius) => {
109
109
*/
110
110
const volHemisphere = ( radius ) => {
111
111
isNumber ( radius , 'Radius' )
112
- return ( 2.0 * Math . PI * radius ** 3 ) / 3.0
112
+ return ( 2.0 * Math . PI * radius ** 3 ) / 3.0
113
113
}
114
114
115
115
const isNumber = ( number , noName = 'number' ) => {
@@ -120,4 +120,4 @@ const isNumber = (number, noName = 'number') => {
120
120
}
121
121
}
122
122
123
- export { volCuboid , volCube , volCone , volPyramid , volCylinder , volTriangularPrism , volPentagonalPrism , volSphere , volHemisphere }
123
+ export { volCuboid , volCube , volCone , volPyramid , volCylinder , volTriangularPrism , volPentagonalPrism , volSphere , volHemisphere }
0 commit comments