Skip to content

Instantly share code, notes, and snippets.

@nblackburn
Created February 10, 2022 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nblackburn/6f41e0596ef1d5e15d59de4e796ea84c to your computer and use it in GitHub Desktop.
Save nblackburn/6f41e0596ef1d5e15d59de4e796ea84c to your computer and use it in GitHub Desktop.
Is Palindrome

Checks if a given word is a palindrome.

Usage

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]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment