0

I using chart package for data analystics

Here is my code:

    const param = ['Country', 'Device_Model', 'MMA', 'Game'] // other parameters i want to use eg: Game (current)
   let arr = []
    const handleChangeParam = () => {
      for (let i = 0; i < context.gameAdData.length; i++) {
        context.gameAdData[i].map((element) =>
          arr.push(element._fieldsProto.!!!Game?!!!.stringValue) // Here is parameter Game
        )
      }
      return arr
    }

here is ss:

chart_ss

I need to replace the 'Game' parameter that I specified in the exclamation point with other parameters in the first line.

The image that comes to my mind is as follows, I click the buttons and pull the relevant data

zanthez
  • 45
  • 6

1 Answers1

0
const param = ['Country', 'Device_Model', 'MMA', 'Game']
  let arr = []
  const handleChangeParam = () => {
  for (let i = 0; i < context.gameAdData.length; i++) {
    context.gameAdData[i].map((element) =>
      arr.push(element._fieldsProto.[param[i]]?.stringValue)
    )
  }
  return arr
}
Konrad
  • 21,590
  • 4
  • 28
  • 64
  • I get an "unexpected token" error where I put x. (where the square brackets start) @Konrad Linkowski ```arr.push(element._fieldsProto.x[param[i]]?.stringValue)``` – zanthez Aug 29 '22 at 20:17