I have been using react for a while and I have observed that I don't usually return anything from function rather just call function, change global variables and so on..

For example consider my [index.js file in react app](https://github.com/irohitb/Elucidata/blob/master/src/container/mainHome.js) 

Here I have this function which formats data for the graph 

```
 graphDataFormating = () => {  
      let m = 0
      let arrayPush = []
      let data = this.state.data["groups"]
      let Datalength = this.state.data["groups"].length  
      this.graphdata = []
        if (!this.state.optionalTask)   Datalength = 1
        for (let i=0; i<Datalength; i++) {
            for (let j=0; j<data[i]["peaks"].length; j++) {
                  arrayPush = []
                for (let k=0; k<data[i]["peaks"][j]["eic"]["rt"].length; k++) {
                    if (this.state.filterIntensity < data[i].peaks[j]["eic"]["intensity"][k] && this.state.filterRt < data[i].peaks[j]["eic"]["rt"][k]) {
                        arrayPush.push({
                            y: (data[i]["peaks"][j]["eic"]["intensity"][k]/1000),
                            x: data[i]["peaks"][j]["eic"]["rt"][k]
                        })
                    }
                }
                this.graphdata[m] = arrayPush
                m++
            }
      }

      this.setState({graphData: this.graphdata})
    }

```

Here, I am not returning anything rather changing my global variables (like this.graphdata[m]) or state `this.setState({graphData: this.graphdata})`

Now, I call this function multiple times in my programme 

```
  userFilterData = (event) => {
    this.setState({[event.target.name]: event.target.value}, () => {
        this.graphDataFormating()
    })
  }

  resetData = () => {
    this.setState({  filterIntensity: -1, filterRt: -1}, () => {
        this.graphDataFormating()
    })
  }

  changetask = () => {
      this.setState({ optionalTask: !this.state.optionalTask}, () => {
        this.graphDataFormating()
      })

```

but all the functions, I have created including the `graphDataFormating()`, I haven't returned anything even for once. 

and since I guess if we don't return anything from js function, it will automatically return undefined? hence I believe all the functions above are returning undefined. 

**With this, I have two questions,** 

Is it a bad practise to not return anything from the function?

If you were to improve this code, what suggestion would you give?