Write a function that checks if a given string s
is a palindrome and outputs true
or false
accordingly.
For this challenge, a palindrome is defined as text that remains unchanged when reversed - for example "mom" or "race car". The check should ignore letter casing (uppercase/lowercase) and skip any characters that aren't letters or numbers.
Constraints:
Examples:
// Example 1:
const s1 = "Was it a car or a cat I saw?";
console.log(isPalindrome(s1));
// Output: true
// Explanation: After considering only alphanumerical characters we have "wasitacaroracatisaw", which is a palindrome.
// Example 2:
const s2 = "tab a cat";
console.log(isPalindrome(s2));
// Output: false
// Explanation: "tabacat" is not a palindrome.