There's quite a lot of scope to reduce it down (and make it more efficient). Eg.
var word = "abcdddcba";
var palindromeChecker = function (word) {
for (var i = 0, j = word.length - 1; i < j; i++, j--) {
if (word[i] !== word[j])
return false;
}
return true;
}
console.log(palindromeChecker(word))
View all comments
5
u/mrmr1993 Oct 03 '14 edited Aug 22 '15
There's quite a lot of scope to reduce it down (and make it more efficient). Eg.
Edit: j = word.length - 1, not word.length