Question: This is from LeetCode - Valid Palindrome.

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

Note: For the purpose of this problem, we define empty string as valid palindrome.

1. while (regex.test(s[start])) {
 start++;}
--> can't understand how it works, I understood only that s[start] is alphanumeric characters, it will be false
2. if (!s[start] || !s[end]) 
--> What does this mean?

Below is the whole code

```
var isPalindrome = function(s) {
    let regex = /[\W]/;
    let start = 0;
    let end = s.length - 1;
    while (start < end) {
        // Moves front runner to next alphanumeric
        while (regex.test(s[start])) {
            start++;
        }
        // Moves back runner to next alphanumeric
        while (regex.test(s[end])) {
            end--;
        }
        // Above would run until null if there are no alphanumeric characters so return true
        if (!s[start] || !s[end]) {
            return true;
        }
        // Check if equal and return false if not
        if (s[start].toLowerCase() != s[end].toLowerCase()) {
            return false;
        }
        // If index values match continue the while loop
        start++;
        end--;
    }
    return true;
};

```

Please Advise!

Answer: 
Same as previous solution, plus:
+ removing spaces and symbols, except (A-Z,a-z,0-9)
+ lowercasing

```
const isPalindrome = function(str) {
  const expr = /[\W_]/g;
  const lowcaseStr = str.toLowerCase().replace(expr, '');
  const reverseStr = lowcaseStr.split('').reverse().join('');
  return lowcaseStr === reverseStr
};

```
This is heavily over-engineered. Why not just use one for loop with 2 counters, one starting at 0 and one at the last index and, while they aren't equal, check if the characters at those indices are the same. Or use built in functions like

```
function palindrome(str){ return str.split('').reverse().join('') == str}

```