Oleksii Trekhleb | Javascript algorithms (Palindrome check)
This is a series of books diving deep into the core mechanisms of the JavaScript language.
· 1 phút đọc.
A Palindrome is a string that reads the same forwards and backwards. This means that the second half of the string is the reverse of the first half.
Examples
The following are palindromes (thus would return TRUE
):
- _a_
- _pop_ -> p + o + p
- _deed_ -> de + ed
- _kayak_ -> ka + y + ak
- _racecar_ -> rac + e + car
The following are NOT palindromes (thus would return FALSE
):
- _rad_
- _dodo_
- _polo_