Accumulator pattern
Keeping one name outside a loop - a total, a count, a largest so far - and updating it every round, so the loop remembers something about every value it has seen.
Depth 1 · Foundation
You can keep a running total, a count, a product or a largest-so-far in a loop, choose the start value that means "nothing seen yet", and spot a total that is reset inside the loop.
Sign in to prove what you know with a short quiz, see how deep you've gone, and earn XP for it.
Sign in with GoogleDepths of understanding
- 1
Foundation
You can keep a running total, a count, a product or a largest-so-far in a loop, choose the start value that means "nothing seen yet", and spot a total that is reset inside the loop.
Your path here
What's still between you and Accumulator pattern, depth 1, in the order you can learn it.
- 1ProgramDepth 1 · Foundation · Program Basics
- 2ExpressionDepth 1 · Foundation · Program Basics
- 3Variables in codeDepth 1 · Foundation · Program Basics
- 4Program stateDepth 1 · Foundation · Program Basics
- 5Input and outputDepth 1 · Foundation · Program Basics
- 6Functions in codeDepth 1 · Foundation · Functions
- 7Return valuesDepth 1 · Foundation · Functions
- 8BooleansDepth 1 · Foundation · Control Flow
- 9ConditionalsDepth 1 · Foundation · Control Flow
- 10LoopsDepth 1 · Foundation · Control Flow
- 11Accumulator patternDepth 1 · Foundation · Control Flow