Recursion: String Palindromes

Published by Helen Yu in

Write a function that recursively determines if a string is a palindrome.

Examples

palindrome("abcba") ➞ true

palindrome("b") ➞ true

palindrome("") ➞ true

palindrome("ad") ➞ false

Notes

An empty string counts as a palindrome.

Watch a quick demo on how Edabit works.