Created
October 31, 2017 08:59
-
-
Save KristofferK/b3f517e4f3f3c9275f57794abaf861d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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