📅  最后修改于: 2022-03-11 15:01:39.148000             🧑  作者: Mango
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))