Check if both left and right parts are present in a [ ]
if ( cnt . has ( left ) && cnt . has ( right ) ) { ans = false ; document . write ( b [ i ] + " " ) ; } } } if ( ans ) document . write ( " " ) ; }