Challenge: Sum Array

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

Problem

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

Input

An integer array.

Output

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.

Get hands-on with 1400+ tech skills courses.