Check if a string follows a ^ nb ^ n pattern or not | Returns " Yes " str is of the form a ^ nb ^ n . ; check first half is ' a ' and other half is full of ' b ' ; Driver code ; Function call
function isAnBn ( str ) { let n = str . length ; if ( ( n & 1 ) != 0 ) return " " ; let i ; for ( i = 0 ; i < n / 2 ; i ++ ) if ( str [ i ] != ' ' str [ n - i - 1 ] != ' ' ) return " " ; return " " ; } let str = " " ; document . write ( isAnBn ( str ) ) ;