Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isPalindrome(a, b) {
- if (reverse(a) === b) return true;
- let str = a + b;
- let mid = Math.floor((str.length - 1) / 2);
- if (str.substring(0, mid + 1) === reverse(str.substring(mid)))
- return true;
- else return false;
- }
- // helper function for reversing strings
- function reverse(str){
- if(str === "") return str
- else return reverse(str.substr(1)) + str[0]
- }
Add Comment
Please, Sign In to add comment