reduce sum function javascript code example Example: js sum of array [1, 2, 3, 4].reduce((a, b) => a + b, 0) // Output: 10