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.split(''); | |
return chars.every((char, index) => char === chars[chars.length - 1 - index]); | |
}; |