从面试题中学习

给定一个随机整数,求出其二进制数中“1”的个数

function twoLength(n) { 
    return n.toString(2).split("1").length – 1; 
} 

你可能感兴趣的:(从面试题中学习)