Check if all the palindromic sub | Function to check if the string is palindrome ; Function that checks whether all the palindromic sub - strings are of odd length . ; Creating each substring ; If the sub - string is of even length and is a palindrome then , we return False ; Driver code
function checkPalindrome ( s ) { for ( let i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] != s [ s . length - i - 1 ] ) return false ; } return true ; } function CheckOdd ( s ) { let n = s . length ; for ( let i = 0 ; i < n ; i ++ ) { let x = " " ; for ( let j = i ; j < n ; j ++ ) { x += s [ j ] ; if ( x . length % 2 == 0 && checkPalindrome ( x ) == true ) return false ; } } return true ; } let s = " " ; if ( CheckOdd ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;