7. Sum Array Elements

Given an integer array a. Write a function int SumArray(int[] a) that returns the sum of all array elements.
Example 1
Input: a = [-1, 0, 1]
Output: 0
Explanation: -1 + 0 + 1 = 0
Example 2
Input: a = []
Output: 0
Explanation: The sum of an empty array is 0
Example 3
Input: a = [1, 2, 3]
Output: 6
Explanation: 1 + 2 + 3 = 6
arrayseasy
JavaScript
Loading...
Line 1, Char 1