Language concepts

Accumulator

Try the free JavaScript compiler

A variable preserving a partial computation across iterations. Initialize it to the identity or other appropriate initial state and update it without discarding prior contributions.

Formal Syntax & Structure

javascript syntaxjavascript
let total = 0;

Working Example

Example Snippetjavascript
let total = 0; for(let i=1;i<=3;i++) total += i; console.log(total);
JavaScript Reference