Advertisement
Guest User

Untitled

a guest
Feb 10th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. "use strict"
  2.  
  3. let countBits = function(n) {
  4. n = (n).toString(2);
  5. let arr = n.split("");
  6. let count = 0;
  7. for (let a of arr) {
  8. if (+a == 1) {
  9. ++count
  10. }
  11. }
  12. console.log(count);
  13. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement