# How to Find the Height of an Equilateral Triangle in JavaScript

10/01/2021

Contents

In this article, you will learn how to find the height of an equilateral triangle in JavaScript.

## Finding the height of an equilateral triangle in JavaScript

An equilateral triangle is a triangle in which all three sides are equal in length. In an equilateral triangle, the height is the perpendicular line segment drawn from any vertex to the opposite side. In JavaScript, we can use the following formula to find the height of an equilateral triangle:

``Height = (Math.sqrt(3) / 2) * Side``

where Side is the length of any side of the equilateral triangle, and Math.sqrt(3) is the square root of 3, which is approximately equal to 1.73205.

### Examples

#### Finding the height of an equilateral triangle with a side length of 5 units

``````const side = 5; // in units
const height = (Math.sqrt(3) / 2) * side;
console.log(height); // 4.330127018922194
``````

In this example, the side length is 5 units, and the output is the height of the equilateral triangle, which is approximately 4.33 units.

#### Finding the height of an equilateral triangle with a side length of 10 units

``````const side = 10; // in units
const height = (Math.sqrt(3) / 2) * side;
console.log(height); // 8.660254037844386
``````

In this example, the side length is 10 units, and the output is the height of the equilateral triangle, which is approximately 8.66 units.

#### Finding the height of an equilateral triangle with a side length of 3.7 units

``````const side = 3.7; // in units
const height = (Math.sqrt(3) / 2) * side;
console.log(height); // 3.2082611659575097
``````

In this example, the side length is 3.7 units, and the output is the height of the equilateral triangle, which is approximately 3.21 units.