Find the count of even odd pairs in a given Array | Function to count the pairs in array of the form ( even , odd ) ; variable to store count of such pairs ; Iterate through all pairs ; Increment count if condition is satisfied ; Driver code
function findCount ( arr , n ) { let res = 0 ; for ( let i = 0 ; i < n - 1 ; i ++ ) for ( let j = i + 1 ; j < n ; j ++ ) if ( ( arr [ i ] % 2 == 0 ) && ( arr [ j ] % 2 == 1 ) ) { res ++ ; } return res ; } let a = [ 5 , 4 , 1 , 2 , 3 ] ; let n = a . length ; document . write ( findCount ( a , n ) ) ;