Checks if a given word is a palindrome.
const tests = ['hannah', 'anna', 'kayak', 'apple', 'mom', 'wow', 'rotator', 'radar']
tests.forEach((test) => {
console.log('IS_PALINDROME', test, isPalindrome(test));
});| const isPalindrome = (value) => { | |
| const chars = value.replace(/[^a-zA-Z0-9]/g, '').toLowerCase().split(''); | |
| for (let index = 0; index < chars.length / 2; index++) { | |
| if (chars[index] !== chars[chars.length - 1 - index]) { | |
| return false; | |
| } | |
| } | |
| return true; | |
| }; |