Write a function findPalindromeWords(sentence) that finds all palindrome words in a sentence and returns an object { words, count }.
a-z and A-Z. Every other character (spaces, punctuation, digits, letters with accents such as é) separates words: 'Wow!' is the word wow, and '101' is not a word.'Mom' is a palindrome.words is an array of the palindrome words in lower case, in the order they appear in the sentence. A word that appears twice is in the array twice.count is the number of items in words.{ words: [], count: 0 }.A regular expression such as /[a-z]+/gi finds the words.
findPalindromeWords('Mom and Dad saw a racecar')Returns { words: [ 'mom', 'dad', 'a', 'racecar' ], count: 4 }
findPalindromeWords('Wow! Noon, level.')Returns { words: [ 'wow', 'noon', 'level' ], count: 3 }
Asked at Goomo · Source
findPalindromeWords('Mom and Dad saw a racecar'){ words: [ 'mom', 'dad', 'a', 'racecar' ], count: 4 }findPalindromeWords('This is a test'){ words: [ 'a' ], count: 1 }Hidden tests run on Submit.