Skip to content

Instantly share code, notes, and snippets.

@KristofferK
Created October 31, 2017 08:59
Show Gist options
  • Save KristofferK/b3f517e4f3f3c9275f57794abaf861d4 to your computer and use it in GitHub Desktop.
Save KristofferK/b3f517e4f3f3c9275f57794abaf861d4 to your computer and use it in GitHub Desktop.
const isPalindrome = s => {
if (s.length < 2) return true;
if (s[0] !== s[s.length - 1]) return false;
return isPalindrome(s.substr(1, s.length - 2));
}
const testPalindrome = palindromeMethod => s => {
const result = palindromeMethod(s) ? "er et palindrom" : "er IKKE et palindrom";
console.log(s, result);
}
const stringsToTest = ["den laks skal ned", "mellem", "tigerrejer"];
const palindromeTester = testPalindrome(isPalindrome);
stringsToTest.forEach(palindromeTester);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment