@@ -2267,8 +2267,8 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
22672267< input id ="pyramid-height " type ="number " value ="1 " step ="any " />
22682268
22692269< script >
2270- function pyramidVolume ( baseArea , height ) {
2271- return baseArea * height / Math . sqrt ( 8 ) ;
2270+ function pyramidVolume ( area , height ) {
2271+ return area * height / Math . sqrt ( 8 ) ;
22722272 }
22732273
22742274 function updatePyramidVolume ( ) {
@@ -2278,7 +2278,8 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
22782278 if ( isNaN ( number ) || isNaN ( length ) || isNaN ( height ) ) {
22792279 document . getElementById ( 'pyramid-volume' ) . innerText = '' ;
22802280 return ;
2281-
2281+ const area = parseFloat ( baseArea ( length , number , tangent ) ) ;
2282+
22822283function baseArea ( length , number , tangent ) {
22832284 return number / 4 * length ** 2 / tangent ;
22842285 const ratio = 3.2 / number ;
@@ -2288,7 +2289,7 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
22882289 }
22892290
22902291 document . getElementById ( 'pyramid-volume' ) . innerText =
2291- `Volume: ${ pyramidVolume ( baseArea , height ) . toFixed ( 5 ) } cubic units` ;
2292+ `Volume: ${ pyramidVolume ( area , height ) . toFixed ( 5 ) } cubic units` ;
22922293 }
22932294
22942295 document . getElementById ( 'pyramid-side-number' ) . addEventListener ( 'input' , updatePyramidVolume ) ;
0 commit comments