===== ISTEM =====
Solve the following programming task.

TASK: Single Number

Write a function 'singleNumber(nums)' that finds the one element that appears exactly once in an array where every other element appears twice, using O(n) time and O(1) extra memory.

STARTER CODE (javascript):
function singleNumber(nums) {
  // Write your code here
}

module.exports = { singleNumber };


RULES:
- Keep the function name and signature EXACTLY as given.
- Return working code only. No explanations.
- Put the code in a single ``` block.
- Try to solve it first. If you genuinely cannot, write only this single
  line instead of producing faulty code: CANNOT_SOLVE

===== HAM YANIT =====
```javascript
function singleNumber(nums) {
  return nums.reduce((acc, val) => acc ^ val, 0);
}
```