Easy Javascript solution
javascript\n\nvar longestPalindrome = function (words) {\n  // store the word in a map with total count\n  const map = {};\n  let count = 0;\n\n  for (const wor
``` javascript\n\nvar longestPalindrome = function (words) {\n  // store the word in a map with total count\n  const map = {};\n  let count = 0;\n\n  for (const word of words) {\n    if (!map[word]) map[word] = 1;\n    else {\n      map[word] += 1;\n    }\n  }\n\n  let flag = false;\n  for (const word of words) {\n    const reverse = word[1] + word[0];\n    if (word === reverse) {\n      while (map[word] >= 2) {\n        map[word] -= 2;\n        count += 4;\n      }\n      if (map[word] === 1 && !flag) {\n        // only we need to take one word with same pairs which give us an advantage for center letter pair\n        // anymore similar pair will not help so we make flag to true\n        flag = true;\n        count += 2;\n        map[word] -= 1;\n      }\n      continue;\n    }\n    while (map[word] > 0 && map[reverse] > 0) {\n      map[word] -= 1;\n      map[reverse] -= 1;\n      count += 4;\n    }\n  }\n\n  return count;\n};\n```\n
['JavaScript']