Learn
Exam

Calculate the Sum of Array Elements

Difficulty
STARTER

Problem

Given an array numbers of integer elements, write a function solution that returns the sum of the elements in numbers.


Constraints

  • Each element in numbers is an integer with an absolute value not exceeding 500.
  • numbers is not empty, and its length does not exceed 100.

Test Case

Test Case Number numbers return
1 [1] 1
2 [1, 2, 3, 4] 10
3 [-200, -10, 0, 10, 200] 0

Explanation for Test Case 1

  • numbers has a single element 1, so the sum is 1.

Explanation for Test Case 2

  • The sum of the elements in numbers is 1 + 2 + 3 + 4 = 10.

Explanation for Test Case 3

  • The sum of the elements in numbers is -200 + -10 + 0 + 10 + 200 = 0.