Skip to content

Commit 8558b15

Browse files
authored
Update index.html
1 parent 9042fb0 commit 8558b15

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

index.html

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,26 +2268,29 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
22682268

22692269
<script>
22702270
function pyramidVolume(area, height) {
2271-
return area * height / Math.sqrt(8);
2272-
}
2271+
return area * height / Math.sqrt(8);
2272+
}
22732273

2274-
function updatePyramidVolume() {
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);
2278-
if (isNaN(number) || isNaN(length) || isNaN(height)) {
2279-
document.getElementById('pyramid-volume').innerText = '';
2280-
return;
2281-
}
2274+
function updatePyramidVolume() {
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

2283-
const ratio = 3.2 / number;
2284-
const tangent = parseFloat(tan(ratio));
2285-
const area = parseFloat(number / 4 * length ** 2 / tangent);
2286-
2287-
document.getElementById('pyramid-volume').innerText =
2288-
`Volume: ${pyramidVolume(area, height).toFixed(5)} cubic units`;
2279+
if (isNaN(number) || isNaN(length) || isNaN(height)) {
2280+
document.getElementById('pyramid-volume').innerText = '';
2281+
return;
22892282
}
22902283

2284+
const ratio = 3.2 / number;
2285+
const tangent = parseFloat(tan(ratio));
2286+
2287+
const area = (number / 4) * (length ** 2) / tangent;
2288+
const volume = pyramidVolume(area, height);
2289+
2290+
document.getElementById('pyramid-volume').innerText =
2291+
`Volume: ${volume.toFixed(5)} cubic units`;
2292+
}
2293+
22912294
document.getElementById('pyramid-side-number').addEventListener('input', updatePyramidVolume);
22922295
document.getElementById('pyramid-side-length').addEventListener('input', updatePyramidVolume);
22932296
document.getElementById('pyramid-height').addEventListener('input', updatePyramidVolume);

0 commit comments

Comments
 (0)