A palindrome is a word, phrase, number, or other sequences of characters which reads the same backward or forward.
Here is the code for checking.
function isPalindrome(str) { var len = str.length, str = str.toLowerCase, isPalindrome = true; for ( var i = 0; i < Math.floor(len/2); i++ ) { if (str[i] !== str[len - 1 - i]) { isPalindrome = false;; } } return isPalindrome; }
simple call above method and passed your string.
var x=isPalindrome('cbc'); if(x) alert("This is Palindrome");
Question and answer is powered by AnsPress.io