DEV Community

loading...

Discussion on: Finding the Only Single Number in an Array

Collapse
khuongduybui profile image
Duy K. Bui

I will put this here and let the curious research bitwise XOR with numbers ;)

function xor(nums) {
  return nums.reduce((result, current) => result ^ current);
}
Enter fullscreen mode Exit fullscreen mode