Home > Mobile >  Calculate Total in React Map
Calculate Total in React Map

Time:05-05

I need to calculate the total example the OrdQty. I need to calculate and show it at the bottom.

Image

Currently, there are few tables I have mapped to print the other data. I need help in printing the total ouput.

CodePudding user response:

you just have to create a const with a useState and update the value in your map or do a const with a forEach and return the total.

CodePudding user response:

You can use a reduce function too depending on how your data is structured : https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce

  • Related