-4

If I have an Array of some numbers.

Ex. var num =[123, 234, 12, 0, 23, 19];

How can I get a total of all these elements = 411;

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 3
    [self-answering](https://stackoverflow.com/help/self-answer) is encouraged on Stack Overflow. But, please make sure it is not asked before. Getting the sum of an array of numbers is one of the most frequently asked questions. There is no need to ask it again. – adiga May 04 '21 at 13:15

1 Answers1

-3

Try This, it is the most recommended method to use. Even in SAP -Fiori standard code, this method is used.

var num =[123, 234, 12, 0, 23, 19]; var total = num.reduce((a, b) => a + b, 0);