Modify a bit at a given position | Returns modified n . ; Driver code
function modifyBit ( n , p , b ) { let mask = 1 << p ; return ( n & ~ mask ) | ( ( b << p ) & mask ) ; } document . write ( modifyBit ( 6 , 2 , 0 ) + " " ) ; document . write ( modifyBit ( 6 , 5 , 1 ) ) ;