JavaScript: it's much faster with the bitwise operators `&` and `>>`
Intuition\nAlthough you can use .toString(2) to get a binary string, this is slower and less efficient.\n\nLet\'s calculate each bit of the number one by one. \
# Intuition\nAlthough you can use `.toString(2)` to get a binary string, this is slower and less efficient.\n\nLet\'s calculate each bit of the number one by one. \n\n# Code\n```\nconst evenOddBit = function(n) {\n    let even = 0;\n    let odd = 0;\n    let i = 0;\n\n    while (n > 0) {\n        if (n & 1) { // "if n is an odd number"\n            if (i % 2 === 0) { // can also write `if (!(i & 1))`\n                even++;\n            } else {\n                odd++;\n            }\n        }\n\n        i++;\n        n >>= 1; // remove one bit from `n`, i.e. shift it by one bit\n    }\n\n    return [even, odd];\n};\n```
['JavaScript']