Check given string is oddly palindrome or not | Function to check if the string str is palindromic or not ; Iterate the string str from left and right pointers ; Keep comparing characters while they are same ; If they are not same then return false ; Return true if the string is palindromic ; Function to make string using odd indices of string str ; Functions checks if characters at odd index of the string forms palindrome or not ; Make odd indexed string ; Check for Palindrome ; Given string ; Function Call
function isPalindrome ( str ) { var l = 0 ; var h = str . length - 1 ; while ( h > l ) { if ( str [ l ++ ] != str [ h -- ] ) { return false ; } } return true ; } function makeOddString ( str ) { var odd = " " ; for ( var i = 1 ; i < str . length ; i += 2 ) { odd += str [ i ] ; } return odd ; } function checkOddlyPalindrome ( str ) { var odd = makeOddString ( str ) ; if ( isPalindrome ( odd ) ) document . write ( " " ) ; else document . write ( " " ) ; } var str = " " ; checkOddlyPalindrome ( str ) ;