Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--------------------------------------------
- //Write a function that calculates a triangle’s area by its 3 sides.
- //The input comes as three number arguments, representing one side of a triangle.
- //The output should be printed to the console.
- //--------------------------------------------
- function triangleArea(sideA, sideB, sideC) {
- let a = sideA
- let b = sideB
- let c = sideC
- let s = (a + b + c) / 2
- let area = Math.sqrt(s * (s-a) * (s-b) * (s-c))
- console.log(area)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement