Find the count of even odd pairs in a given Array | Function to count the pairs in array of the form ( even , odd ) ; check if number is even or not ; Driver code
function findCount ( arr , n ) { let count = 0 , ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) count ++ ; else ans = ans + count ; } return ans ; } let a = [ 5 , 4 , 1 , 2 , 3 ] ; let n = a . length ; document . write ( findCount ( a , n ) ) ;