JS don't convert number to string!
It is more efficient in both time and memory to manipulate a number instead of converting to a string in order to check if it is a palindrome number\n\nCode inp
It is more efficient in both time and memory to manipulate a number instead of converting to a string in order to check if it is a palindrome number\n\nCode inpired by [Spaulding_](https://leetcode.com/problems/minimum-cost-to-make-array-equalindromic/solutions/4417892/python-3-6-lines-two-pointers-t-s-364-ms-29-mb/)\n\n\n# Code\n```\nconst isPalindrome = (n) => {\n    let original = n;\n    let reversed = 0;\n\n    while (n) {\n        reversed = reversed * 10 + n % 10;\n        n = Math.floor(n / 10);\n    }\n\n    return original === reversed;\n};\n\nconst minimumCost = (nums) => {\n    nums.sort((a, b) => a - b);\n    const mid = nums.length >> 1;\n    let l = r = nums[mid];\n\n    while (!isPalindrome(l)) l--;\n    while (!isPalindrome(r)) r++;\n\n    return Math.min(\n        nums.reduce((tot, num) => tot + Math.abs(num - l), 0),\n        nums.reduce((tot, num) => tot + Math.abs(num - r), 0)\n    );\n}\n```
['JavaScript']