easy understanding using toString() method js
Intuition\n Describe your first thoughts on how to solve this problem. \n convert the integer to binary and calc odd or even if bit value is 1. reverse\n# Appro
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n convert the integer to binary and calc odd or even if bit value is 1. reverse\n# Approach\n<!-- Describe your approach to solving the problem. -->\ntrack of odd and even indexes and loop over the binary indexes and check for the conditions\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\n/**\n * @param {number} n\n * @return {number[]}\n */\nvar evenOddBit = function (n) {\n  let binaryN = n.toString(2).split("").reverse();\n  let odd = 0;\n  let even = 0;\n  for (let i = 0; i < binaryN.length; i++) {\n    if (binaryN[i] == 1) {\n      if (i % 2 == 0) even++;\n      else odd++;\n    }\n  }\n  return [even, odd];\n};\n```
['JavaScript']