.push() array method don’t seem to be working on accumulator .reduce method

why is .push() method not working on an array in an accumulator object in .reduce() method

let a = [];
for (let i = 0; i <= 20; i++) {
  a.push(i);
}

let {
  even,
  odd
} = a.reduce((acc, val) => {
  val % 2 === 0 ? acc.even.push(val) : acc.odd.push(val);
}, {
  even: [],
  odd: []
});

Answer

Here’s the OP function, returning the accumulator.

  let a = [];
  for (let i = 0; i <= 20; i++) {
    a.push(i);
  }
  
  let result = a.reduce((acc, val) => {
    val % 2 === 0 ? acc.even.push(val) : acc.odd.push(val);
    return acc;
  }, { even: [], odd: [] });
  
  console.log(result)