Skip to content

Commit a64978c

Browse files
authored
Update index.html
1 parent b0a1867 commit a64978c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,8 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
10941094
<input id="side3" type="number" value="1" step="any" />
10951095

10961096
<script>
1097-
function triangleArea(side1, side2, side3, s) {
1098-
return math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
1097+
function triangleArea(product) {
1098+
return math.sqrt(product);
10991099
}
11001100

11011101
function updateTriangleArea() {
@@ -1107,8 +1107,12 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
11071107
return;
11081108
}
11091109

1110-
const s = side1+side2+side3;
1111-
const area = triangleArea(side1, side2, side3, s);
1110+
const s = side1 + side2 + side3;
1111+
const s1 = side2 + side3;
1112+
const s2 = side1 + side3;
1113+
const s3 = side1 + side2;
1114+
const product = parseFloat((s * s1 * s2 * s3).toFixed(5));
1115+
const area = triangleArea(product);
11121116

11131117
document.getElementById('triangle-area').innerText =
11141118
`Area: ${area.toFixed(5)} square units`;

0 commit comments

Comments
 (0)