Search Your Question...!

Showing posts with label Area of Triangle using Javascript. Show all posts
Showing posts with label Area of Triangle using Javascript. Show all posts

Area of Triangle using Javascript

You are given 3 sets of coordinates that form a triangle. Write code to find the area of the triangle enclosed by those coordinates.

For example, the 3 points have coordinates given as x = [0, 3, 6] and y = [0, 3, 0], aligned by index, so the coordinates are [0,0], [3,3], [6,0]. The height of the triangle is 3, and the width is 6, so the area of the triangle is 6 * 3 / 2 = 9. All resulting areas will be whole numbers. Not all triangles will contain a right angle.