This is the problem I'm trying to solve:
Write a Javascript code that checks whether a passed string is palindrome or not? Note: A palindrome is a word or phrase that reads the same backward as forward; eg. madam,racecar, etc.
And this is my code for it.. I'm not sure why it's not working. Can anyone assist?
function is_Palindrome (str){
array1 = str.split('')
array1_orig = array1.map(a => a)
array2 = array1.reverse()
console.log(array1_orig)
console.log(array2)
for (let i = 0; i <array1.length; i++){
if(array1[i] === array2[i]){
console.log("a match")
}
else{
console.log("not a match")
}
}
}
is_Palindrome("desk")
is_Palindrome("desk")
desk is obviously NOT a palindrome, so it should return "not a match" but the code isn't doing that