text: String obtained by reversing and complementing a Binary string K times | Function to perform K operations upon the string and find modified string ; Number of reverse operations ; Number of complement operations ; If rev is odd parity ; If complement is odd parity ; Complementing each position ; Return the modified string ; Driver Code ; Function call
code: function ReverseComplement ( s , n , k ) { var rev = parseInt ( ( k + 1 ) / 2 ) ; var complement = k - rev ; if ( rev % 2 ) { s = s . split ( ' ' ) . reverse ( ) . join ( ' ' ) ; } if ( complement % 2 ) { for ( var i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) s [ i ] = ' ' ; else s [ i ] = ' ' ; } } return s ; } var str = " " ; var k = 5 ; var n = str . length ; document . write ( ReverseComplement ( str , n , k ) ) ;