Area of the Largest Triangle inscribed in a Hexagon | Function to find the area of the triangle ; side cannot be negative ; area of the triangle ; Driver code
function trianglearea ( a ) { if ( a < 0 ) return - 1 ; var area = ( 3 * Math . sqrt ( 3 ) * Math . pow ( a , 2 ) ) / 4 ; return area . toFixed ( 4 ) ; } var a = 6 ; document . write ( trianglearea ( a ) ) ;