Check whether triangle is valid or not if three points are given | Function to check if three points make a triangle ; Calculation the area of triangle . We have skipped multiplication with 0.5 to avoid floating point computations ; Condition to check if area is not equal to 0 ; Driver Code
function checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) { let a = x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ; if ( a == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } let x1 = 1 , x2 = 2 , x3 = 3 , y1 = 1 , y2 = 2 , y3 = 3 ; checkTriangle ( x1 , y1 , x2 , y2 , x3 , y3 ) ;