Loop & Filter

Process arrays with array methods

function processNumbers({ numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }) {
  let evens = numbers.filter((x) => x % 2 == 0)
  let doubled = evens.map((x) => x * 2)
  let total = doubled.reduce((acc, x) => acc + x, 0)
  return { evens, doubled, total }
}