// Create a function that checks if a given string is a palindrome. // A palindrome is text that reads the same forwards and backwards, disregarding puncation, spaces, etc. const testStrings = [ "b", "aba", "abc", // FALSE "abba", "Race Car", "Mr. Owl ate my metal worm", "This is not a palindrome", // FALSE "Ya! Pizza zip pizazz! I pay.", "Doc, Note: I Dissent. A Fast Never Prevents A Fatness. I Diet On Cod.", ]; function isPalindrome(str) { let result; const cleanStr = str .toLowerCase() .match(/[A-Za-z]+/g) .join(''); for (let index in cleanStr) { if (cleanStr[index] === cleanStr[(cleanStr.length - index) - 1]) { result = true; } else { result = false; break; } } return result; } // Test Strings testStrings.forEach(function(str) { console.log(`isPalindrome:${isPalindrome(str)}`, str); });