Published
Edited
Feb 5, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// experiments are an array of objects with a name and a function to run.
experiments = [
{
name: "D3 Sum",
run: () => d3.sum(values)
},
{
name: "For Loop Sum",
run: () => {
let sum = 0;
for (let i = 0, n = values.length; i < n; i++) {
sum += values[i];
}
return sum;
}
},
{
name: "For of Loop Sum",
run: () => {
let sum = 0;
for (const v of values) {
sum += v;
}
return sum;
}
},
{
name: "Reduce Sum",
run: () => values.reduce((a, b) => a + b, 0)
}
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more