The Hamming weight is the number of 1's of the binary representation of a given number.
Write and export as default a function calculating the Hamming weight.
hammingWeight(0); // 0 hammingWeight(4); // 1 hammingWeight(101); // 4
- toString() method will help convert a number into binary
For full access to the challenge you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.