Good morning,
Today’s Byte |
This question is asked by Facebook. Given a string, return whether or not it forms a palindrome ignoring case and non-alphabetical characters.
Note: a palindrome is a sequence of characters that reads the same forwards and backward.
Ex: Given the following strings…
"level", return true
"algorithm", return false
"A man, a plan, a canal: Panama.", return true
1 2 3 4 | function validPanindrome(str){ let temp = str.toLowerCase().replace(/[^a-z0-9]/g,"") return temp === temp.split("").reverse().join("") } |