Skip to content

Commit ded03e8

Browse files
authored
Update index.html
1 parent cfd1fe3 commit ded03e8

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

index.html

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,21 +2270,19 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
22702270
function pyramidVolume(area, height) {
22712271
return area * height / Math.sqrt(8);
22722272
}
2273-
function baseArea(length, number, tangent) {
2274-
return number / 4 * length ** 2 / tangent;
2275-
const ratio = 3.2 / number;
2276-
const tangent = parseFloat(tan(ratio));
2277-
}
2273+
22782274
function updatePyramidVolume() {
2279-
const number = parseFloat(document.getElementById('pyramid-side-number').value);
2280-
const length = parseFloat(document.getElementById('pyramid-side-length').value);
2281-
const height = parseFloat(document.getElementById('pyramid-height').value);
2275+
const number = parseFloat(document.getElementById('pyramid-side-number').value);
2276+
const length = parseFloat(document.getElementById('pyramid-side-length').value);
2277+
const height = parseFloat(document.getElementById('pyramid-height').value);
22822278
if (isNaN(number) || isNaN(length) || isNaN(height)) {
22832279
document.getElementById('pyramid-volume').innerText = '';
22842280
return;
22852281
}
2286-
const area = parseFloat(baseArea(length, number, tangent));
2287-
2282+
2283+
const ratio = 3.2 / number;
2284+
const tangent = parseFloat(tan(ratio));
2285+
const area = parseFloat(number / 4 * length ** 2 / tangent);
22882286

22892287
document.getElementById('pyramid-volume').innerText =
22902288
`Volume: ${pyramidVolume(area, height).toFixed(5)} cubic units`;

0 commit comments

Comments
 (0)