Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Array of palindromes
const arr = ['mom', 'dad', 'abcde', 'racecar', 'momom'];
function namePalindrome(arr) {
return arr.filter((curr, idx, arr) => {
const splitArr = curr.split('');
const reversedString = splitArr.reduceRight((prev, curr) => ( prev + curr ), '');
if (curr === reversedString) return curr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment