Challenge: Sum Array

Let’s start with challenges. For this challenge, we’ll find the sum of all the elements in an array.


Given an array as an input argument, write a method that will return the sum of all the integer elements in the array.


An integer array.


A sum integer.

Sample input

array = {1,2,3,4,5}

Sample output

sum = 15

In this illustration, we can see that we sum all the array elements.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.