JSFiddle - React, Tailwind, and code Playground
by Simonwep
HTML
<body>
</body>
JavaScript
const getOneBits = n => {
let count = 0;
for (let i = 512; i > 0; i = i >> 1) {
if (n & i) {
count++;
}
}
return count;
}
document.body.innerHTML = getOneBits(333);