# Running Sum of an Array

Today we are going to look at an algorithm called running sum of an Array. We want to take an array [1,2,3,4] and we want to add these numbers as we go along and add them to an array such that our output is [1,3,6,10]. So how do we tackle such a problem?

First, we need to create a sum variable. We have to keep track of the total number.

Then we need to create a new array variable so that we don't have to mutate the input.

After that, we get into the meat of the problem! We don’t know how long the input nums is, so we will have to make a for loop. Inside the for loop we want to set the next sum by adding the previous sum to the new number we are looking at.

Nice! We’re moving right along. Since now we have our new sum, we need to add it to the array so that we have something to return! We do that with the push method.

Finally, our last step is to return the array!