```
/**
* @param {number} x
* @param {number} y
* @return {number}
*/
var hammingDistance = function(x, y) {
let diff = x ^ y;
let result = 0;
// find number of ones in the XOR result
while (diff > 0) {
if (diff & 1 === 1) result += 1;
diff >>= 1;
}
return result;
};
```