I have been trying to make an input that gets a array and checks if it is a palindrome number or not, by the locations of the numbers (with i = 0
and j = array.length
).
I just don't know how can I continue from here and what is wrong with my code.
That is my function:
function isPalindrome() {
var input;
var array = input.split("");
var i = 0;
var j = array.length;
while (i < j) {
if (array[i] != array[j]) {
return false;
} else {
i++;
j--;
}
}
return true;
}