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;
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;
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);