Member-only story
On the algorithm, Simple Array Sum, you are given an array of integers and you are to find the sum of its elements.
The input of the function simpleArraySum, you are given an array. You can think of an array like a train:
You can think of a train being an array and each railroad car contains an item. That item can be a string, numbers, or another array. Because we are trying to find the sum of something, the items in the array will be a number. For this example, the array will contain four numbers.
Before we do something to the array, you’ll need a variable to hold the sum. We can name the variable total. A way to begin this is to assign the first item in the array to the variable. Computers start counting at zero so to get the first item of an array, you write total[0]. Zero is the first item.