text: Area of a n | Function to find the area of a regular polygon ; Side and side length cannot be negative ; Area degree converted to radians ; Driver code
code: function polyarea ( n , a ) { if ( a < 0 && n < 0 ) return - 1 ; var A = ( a * a * n ) / ( 4 * Math . tan ( ( 180 / n ) * 3.14159 / 180 ) ) ; return A ; } var a = 9 , n = 6 ; document . write ( polyarea ( n , a ) . toFixed ( 5 ) ) ;