In this case, I'm making a sum of the object and its working just as I wanted to, the problem is the following message:
Expected to return a value in arrow function array-callback-return
Here is the code:
data.map((current,index, array) => {
const prevVisitors = array[index - 1 ] ? array[index - 1].visitors : 0
current.visitors += prevVisitors
})
What should I use as a return statement if there is nothing to be returned(Since it's only a modification of the props)? And in what cases this error is useful?
mapworks that you need to return the changed value so you canreturn currentafter you changed it, even if in these cases aforEachcould be more suitable