Skip to content

Instantly share code, notes, and snippets.

@weblancaster
Created October 27, 2016 15:44
Show Gist options
  • Save weblancaster/0861f7070a3a44866ab8cae9a5c62584 to your computer and use it in GitHub Desktop.
Save weblancaster/0861f7070a3a44866ab8cae9a5c62584 to your computer and use it in GitHub Desktop.
Check if string is palindrome in Javascript.
function isPalindrome(str) {
str = str.replace(/\W/g).toLowerCase();
return str === str.split('').reverse().join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment