Check whether array is a palindrome in Javascript
· ☕ 1 min read
Check whether a given array has a palindrome in Javascript.
Below logic should be fast, if not the fastest.
1 2 3 4 5 6 7 8 9 10 11 console.log(checkPalindrome([1, 3, 5, 3, 1])); function checkPalindrome(arr) { const len = arr.length; if (len % 2 == 0) return false; for (let i = 0; i < len / 2; i++) { if (arr[i] !