Open this example in the interactive library
Source code
const xs = [3, 5, 10];
console.log(xs.reduce((a, b) => a + b, 0) / xs.length);
Sample output
6

Calculate an average. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const xs = [3, 5, 10];
console.log(xs.reduce((a, b) => a + b, 0) / xs.length);
6