Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dadeg on github.
  • I am dandegreef (https://keybase.io/dandegreef) on keybase.
  • I have a public key whose fingerprint is 805A 38C1 AEC8 7AB2 4B62 B713 7F43 B7C6 8709 9381

To claim this, I am signing this object:

@dadeg
dadeg / isPalindrome.js
Created April 21, 2016 19:58
javascript function for determining if a string is a palindrome.
var isPalindrome = (input) => {
if (typeof input !== 'string' && !Array.isArray(input)) { throw "isPalindrome() requires a string or array as an argument."; }
if (typeof input === 'string') { input = input.split(""); }
let one = input.pop();
let two = input.shift();
if (two === undefined) { return true; }
if ( one === two ) { return isPalindrome(input); }
return false;
}
console.log(isPalindrome('a')); // true