October 27, 2022 |1.9K Views

    Javascript program to find the area and perimeter of the triangle

      Share   Like
    Description
    Discussion

    In this video, we will write a Javascript program to find the area & perimeter of triangles.

    Area of a Triangle:
    The area of a triangle is defined as the total space occupied by the three sides of a triangle in a 2- dimensional plane.
    Formula:
    A = 1/2 × b ×h

    The Perimeter of a Triangle:
    To calculate the perimeter of a triangle, we just add the length of its all sides. 
    Suppose, if a triangle has sides x, y, and z, also the perimeter of that triangle will be:
    P = (x+y+z)

    Example: 
    Input 
    h and b : 3 & 4
    Output 
    Area = 6
    Perimeter = 10

    Now, in this video, we calculate the area & perimeter of the triangle using 2 different methods:
    1. Using simple formula [height and base of the triangle]
    2. Using the user to define a function

    Apart from that the time and space complexity covered in this video.

    Javascript program to find the area & perimeter of triangles :
    https://www.geeksforgeeks.org/how-to-find-the-area-of-a-triangle-using-javascript/