text: Middle of three using minimum comparisons | Javascript program to find middle of three distinct numbers ; Function to find the middle of three number ; Checking for b ; Checking for a ; driver code
code: function middleOfThree ( a , b , c ) { function middleOfThree ( $a , $b , $c ) { if ( ( a < b && b < c ) || ( c < b && b < a ) ) return b ; else if ( ( b < a && a < c ) || ( c < a && a < b ) ) return a ; else return c ; } let a = 20 , b = 30 , c = 40 ; document . write ( middleOfThree ( a , b , c ) ) ;