Sum

We'll cover the following...

So far, we’ve just used one mutable variable to keep track of where we are in the loop. But we’re not limited to that. We can also use a mutable variable to keep track of a result. This is sometimes known as an accumulator since we’re accumulating a result value at each iteration. We can use this technique to add the numbers from 1 to 10.

Access this course and 1400+ top-rated courses and projects.