Program to find slope of a line | function to find the slope of a straight line ; driver code to check the above function
function slope ( x1 , y1 , x2 , y2 ) { if ( x1 == x2 ) return Number . MAX_VALUE ; return ( y2 - y1 ) / ( x2 - x1 ) ; } var x1 = 4 , y1 = 2 ; var x2 = 2 , y2 = 5 ; document . write ( " " + slope ( x1 , y1 , x2 , y2 ) ) ;