Skip to content

Instantly share code, notes, and snippets.

@telingadigital
Created February 6, 2018 17:14
Show Gist options
  • Save telingadigital/f7602a6a5e5172b9d90876ceb180b274 to your computer and use it in GitHub Desktop.
Save telingadigital/f7602a6a5e5172b9d90876ceb180b274 to your computer and use it in GitHub Desktop.
Check Whether A String Palindrome Javascript
function isPalindrome(str) {
str = str.match(/[A-Za-z0-9]/gi).join("").toLowerCase();
for(var i = 0; i < Math.floor(str.length/2); i++) {
if(str.charAt(i) !== str.charAt(str.length-i-1)) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment