title: Finding a Single Integer in an array using Javascript
body: <p>I was able to pull all single integers after 'reduce', but not working when there's all duplicates and output should be 0, not hitting my else or else if - code keeps outputting 0 vs the single integers</p>
  
  <pre><code>    var singleNumber = function(nums) {
         var sorted_array = nums.sort();
  
         for (var i=0; i &lt; sorted_array.length; i++){
           var previous = sorted_array[i-1];
           var next = sorted_array[i+1];
           var singles = {key: 0};
           var singlesArray = [];
  
           if (sorted_array[i] !== previous &amp;&amp; sorted_array[i] !== next){
             singlesArray.push(sorted_array[i]);
  
             singlesArray.reduce(function(singles, key){
                 singles.key = key;
                 //console.log('key', key);
                 return singles.key;
            },{});
  
          }
         else if(singlesArray.length === 0) {
            singles.key = 0;
            return singles.key;
           }
       }
      console.log('singles.key', singles.key);
      return singles.key;
     };
  
    console.log(singleNumber([2,1,3,4,4]));
  </code></pre>