Summing numbers in an array.
const arr = Array.from({length: 10000}, (_, i) => i);
Initializing...
const sum = arr.reduce((acc, val) => acc + val, 0);
let sum = 0; for(let i=0; i<arr.length; i++) sum += arr[i];
You can edit these tests or add more tests to this page by appending /edit to the URL.