let countBits = function(n) {
let binary = n.toString(2);
let splitar = binary.split("");
return splitar.reduce((a, b) => parseInt(a) + parseInt(b), 0)
};
console.log(countBits(0))
console.log(countBits(4))
console.log(countBits(7))
console.log(countBits(9))
console.log(countBits(10))