text: Q:
  
  Results in for loop repeated too many times - remove duplicates JS
  
  I am trying to divide the numbers of this array arr([7,3,14,17]) into even and odd numbers. I have done the following:
  
  var arr = [7, 3, 14, 17]
  var o = {
      even: [],
      odd: []
  }
  
  for (var i = 0; i < arr.length; i++) {
      arr.map(e => {
          if (i % 2 === 0) {
              o.even.push(arr[i])
          } else {
              o.odd.push(arr[i])
          }
      });
  }
  console.log(o.even);
  console.log(o.odd);
  
  but the result for the even array is [ 7, 7, 7, 7, 14, 14, 14, 14 ] and for the odd array is [ 3, 3, 3, 3, 17, 17, 17, 17 ]. Why is this happening? How can I end up with only [7, 14] and [3, 17] ? Any suggestion/best practice is appreciated! Thanks a lot!
  
  A:
  
  This is because inside your for loop you have a call to map, which is itself a replacement of a for loop. The fact that you are not using e from the closure should serve as a hint that you are doing something incorrectly. You array has 4 elements, so the for loop calls map 4 times, resulting in 4 duplicates for each value.
  Remove map to fix the problem:
  for (var i = 0; i < arr.length; i++) {
      if (i%2 === 0) {
          o.even.push(arr[i])
      } else {
          o.odd.push(arr[i])
      }
  }
  
  You can also remove for, and keep the map, but you would need a different overload:
  arr.map((e, i) => {
      if (i%2 === 0) {
          o.even.push(arr[i])
      } else {
          o.odd.push(arr[i])
      })
  
  