MCPcopy Index your code
hub / github.com/TheAlgorithms/JavaScript / PalindromeRecursive

Function PalindromeRecursive

Maths/Palindrome.js:17–27  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

15 */
16
17const PalindromeRecursive = (string) => {
18 // Base case
19 if (string.length < 2) return true
20
21 // Check outermost keys
22 if (string[0] !== string[string.length - 1]) {
23 return false
24 }
25
26 return PalindromeRecursive(string.slice(1, string.length - 1))
27}
28
29const PalindromeIterative = (string) => {
30 const _string = string

Callers 1

Palindrome.test.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected