Sunday, April 18, 2021

9. Write a JavaScript function to find the area of a triangle where lengths of the three of its sides are 5, 6, 7.

9. Write a JavaScript function to find the area of a triangle where lengths of the three of its sides are 5, 6, 7.

<script>

var side1 = 5; 
var side2 = 6; 
var side3 = 7; 

var s = (side1 + side2 + side3)/2;
var area =  Math.sqrt(s*((s-side1)*(s-side2)*(s-side3)));
console.log(area);

</script>

No comments: