Binary String of given length that without a palindrome of size 3 | JavaScript program find a binary String of given length that doesn 't contain a palindrome of size 3. ; Printing the character according to i ; Driver code
function generateString ( n ) { var s = " " ; for ( var i = 0 ; i < n ; i ++ ) s += ( ( i & 2 ) > 1 ? ' ' : ' ' ) ; document . write ( s + " " ) ; } var n = 5 ; generateString ( n ) ; n = 8 ; generateString ( n ) ; n = 10 ; generateString ( n ) ;