Javascript Program to Find Area of Triangle Using Base and Height Coordinates Full Project For Beginners

 

Welcome folks today in this blog post we will be calculating area of triangle using base and height coordinates  in javascript. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started create a index.html file and copy paste the code which is shown below

 

In this example we will be calculating area of triangle by height and base coordinates

 

index.html

 

<!DOCTYPE html>
<html>
  <head>
    <title>Add Two Numbers in Javascript</title>
  </head>
  <body>
</body>
<script>
const baseValue = prompt('Enter the base of a triangle: ');
const heightValue = prompt('Enter the height of a triangle: ');

// calculate the area
const areaValue = (baseValue * heightValue) / 2;

alert(
  `The area of the triangle is ${areaValue}`
);
</script>
</html>

 

 

Now if you open index.html file inside the browser you will see the below result

 

 

Leave a Reply