title: Could someone clarify why if I use one variable its wrong but if I change it to another I get the right solution?
body: <p>I am solving this code challenge:
  Create a function <code>countBy</code> that accepts an array and a callback, and returns an object. <code>countBy</code> will iterate through the array and performs the callback on each element. Each return value from the callback will be saved as a key on the object. The value associated with each key will be the number of times that particular return value was returned.</p>
  <p>Below is the code I did</p>
  <pre><code>    function countBy(array, callback){
          let newObj = {}
        let numOdd = 0
        let numEv = 0
        for(let i = 0; i &lt; array.length; i++){
          let callbackRes = callback(array[i])
          if(callback(array[i]) === 'even'){
            numEv++
          }
          else if(callback(array[i]) === 'odd'){
            numOdd++
          }
          newObj[callbackRes] = numOdd
        }
          return newObj
      }
  </code></pre>
  <p>I got the right solution which is:</p>
  <p>{ odd: 3, even: 2 }</p>
  <p>However, I'm not quite sure why that is? At first, I was trying to set</p>
  <pre><code>        newObj[callbackRes] = numEv, numOdd
  </code></pre>
  <p>However, that gave me this solution:</p>
  <pre><code>{ odd: 2, even: 2 }
  </code></pre>
  <p>and I figured out that trying to assign the object to both values just assigns it to the first var.</p>
  <p>Why does setting the obj value to <code>numOdd</code> return a different value than numEv? Shouldn't it be the same since it's going through the same for loop?</p>