Count of Subsets of a given Set with element X present in it | Javascript code to implement the above approach ; N stores total number of subsets ; Generate each subset one by one ; Check every bit of i ; if j 'th bit of i is set,  check arr[j] with X ; Driver code
function CountSubSet ( arr , n , X ) { let N = Math . pow ( 2 , n ) ; let count = 0 ; for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { if ( i & ( 1 << j ) ) if ( arr [ j ] == X ) count += 1 ; } } return count ; } let arr = [ 4 , 5 , 6 , 7 ] ; let X = 5 ; let n = arr . length ; document . write ( CountSubSet ( arr , n , X ) ) ;