Count pairs in an array containing at least one even value | Function to count the pairs in the array such as there is at least one even element in each pair ; Generate all possible pairs and increment then count if the condition is satisfied ; Driver code ; Function call
function CountPairs ( arr , n ) { let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] % 2 == 0 arr [ j ] % 2 == 0 ) count ++ ; } } return count ; } let arr = [ 8 , 2 , 3 , 1 , 4 , 2 ] ; let n = arr . length ; document . write ( CountPairs ( arr , n ) ) ;