how to calculate total using array in javacsript code example Example: javascript sum of array const sum = arr => arr.reduce((a, b) => a + b, 0);