Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 506 Bytes

check-if-a-string-is-a-palindrome.mdx

File metadata and controls

27 lines (21 loc) · 506 Bytes
category contributors created title updated
String
marcobiedermann
2020-05-18
Check if a string is a palindrome
2021-10-13

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