text: Composite XOR and Coprime AND | Function to return the count of odd numbers in the array ; Variable to count odd numbers ; Odd number ; Function to return the count of valid pairs ; Driver Code
code: function countOdd ( arr , n ) { var odd = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) odd ++ ; } return odd ; } function countValidPairs ( arr , n ) { var odd = countOdd ( arr , n ) ; return ( odd * ( odd - 1 ) ) / 2 ; } var arr = [ 1 , 2 , 3 , 4 , 5 ] ; var n = arr . length ; document . write ( countValidPairs ( arr , n ) ) ;