I'm using reduce function and i expect an array to be returned, instead is returning an object. Here's my code so far:
const values = useMemo(() => {
    const result = value.reduce((acc, inc, i) => {
      return {
        ...acc,
        ...Object.values(inc.table).filter((t) => {
          const newObj = _omit(t, ['keyword'])
          const { operator, value } =
            categoriesMap[config[i].category].summary
          const isValid = Object.values(newObj).every(item => item >= value)
          if (
            !(
              categoriesMap[config[i].category].summary &&
              categoriesMap[config[i].category].summary.enable
            )
          ) return false;
          if (isValid) {
            return true
          }
          else {
            return false
          }
        }).map((r) => {
          const newObj = _omit(r, ['keyword'])
          const valueObj = Object.values(newObj).map((i) => i)
          const max = Math.max(...valueObj)
          return {
            [r.keyword]: max
          }
        })
      };
    }, [])
    return result
  }, [config, value, categoriesMap])
Note that value is an array of objects like this:
[{
keyword: 'keyword',
today:9,
yesterday: 8
}]
Here's a log of what values is at the end (result is exactly the same of course):
0: {…}, 1: {…}}0: Programmazione: 8[[Prototype]]: Object1: Robotica: 9[[Prototype]]: Object[[Prototype]]: Object
What i expect :
(2) [{…}, {…}]
0:
Programmazione: 8
[[Prototype]]: Object
1:
Robotica: 9
[[Prototype]]: Object
length: 2
[[Prototype]]: Array(0)
Am i missing something in the reduce function? Any tips are appreciated
 
    