Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For the purpose of this problem, we define empty string as valid palindrome.
Input: "A man, a plan, a canal: Panama"
Output: true
Input: "race a car"
Output: false
/**
* @param {string} s
* @return {boolean}
*/
var isPalindrome = function(s) {
s = s.replace(/[^a-zA-Z0-9]/g,'').toLowerCase();
console.log(s);
for(var i = 0; i<s.length/2+1;++i){
if(s[i] !== s[s.length-1-i]){
return false;
}
}
return true;
};