My question has two parts. I'm trying to check whether a date is a palindrome or not. In the following code, I continuously get the result of "Not a palindrome"
even if the string is in fact a palindrome.
function isPalindrome(str){
var rev = str.reverse;
if(str === rev){
console.log("This is a palindrome.");
}
else{
console.log("Not a palindrome");
}
}
isPalindrome("2002");
The second part to my question is: if I wanted the function to take two arguments function isPalindrome(start_date, end_date)
and have it check the dates between for palindrome years and then return those years chronologically, how do I do that? I'm not asking for anyone to actually do it for me. I'm just asking for an explanation on how to accomplish it.
Thanks in advance.