I'm on a code wars exercise and its not accepting my solution, and throws a type error: Cannot read property 'length' of null. I checked my code on a separate Chrome window and it works perfectly. When the function is called with any integer, I get all the 1's from the binary number. What am I doing wrong?
var countBits = function(n) {
var result = n.toString(2).match(/1/g).length;
return result;
};