diff --git a/bangdori/Valid Palindrome.js b/bangdori/Valid Palindrome.js new file mode 100644 index 0000000..0b4a2f3 --- /dev/null +++ b/bangdori/Valid Palindrome.js @@ -0,0 +1,22 @@ +/** + * @param {string} s + * @return {boolean} + */ +var isPalindrome = function (s) { + const removedNonAlphanemuricString = [...s.toLowerCase()].filter( + (alpha) => isLowerAlphabet(alpha) || isNumeric(alpha) + ); + + return ( + removedNonAlphanemuricString.join("") === + removedNonAlphanemuricString.reverse().join("") + ); +}; + +function isLowerAlphabet(character) { + return character >= "a" && character <= "z"; +} + +function isNumeric(character) { + return character >= "0" && character <= "9"; +}