Skip to main content

Check if a string is a palindrome

JavaScript version

const isPalindrome = (str) => str === str.split('').reverse().join('');

TypeScript version

const isPalindrome = (str: string): boolean => str === str.split('').reverse().join('');

Examples

isPalindrome('abc'); // false
isPalindrom('abcba'); // true

Comments