Skip to content

Instantly share code, notes, and snippets.

@bensmithett
Forked from nathansmith/palindrome.js
Created December 20, 2012 22:10
Show Gist options
  • Save bensmithett/4348996 to your computer and use it in GitHub Desktop.
Save bensmithett/4348996 to your computer and use it in GitHub Desktop.
function is_palindrome(str) {
str = str.toString();
return str === str.split('').reverse().join('');
}
/*
// Usage...
is_palindrome('racecar'); // true
is_palindrome(45654); // true
is_palindrome('hello'); // false
is_palindrome(12345); // false
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment