Find bitwise OR of all possible sub | function to return OR of sub - arrays ; Driver Code ; print OR of all subarrays
function OR ( a , n ) { var ans = a [ 0 ] ; for ( var i = 1 ; i < n ; ++ i ) ans |= a [ i ] ; return ans ; } var a = [ 1 , 4 , 6 ] ; var n = a . length ; document . write ( OR ( a , n ) ) ;