Public
Edited
Apr 25
Insert cell
Insert cell
viewof myArrayOperations = {
const svg = d3.select(DOM.svg(500, 500));

const array = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];

const results = [
`Min: ${d3.min(array)}`,
`Max: ${d3.max(array)}`,
`Extent: ${d3.extent(array)}`,
`Mean: ${d3.mean(array)}`,
`Median: ${d3.median(array)}`,
`Sum: ${d3.sum(array)}`,
`Sorted Descending: [${array.sort(d3.descending).join(", ")}]`,
`After Shift: [${(array.shift(), array.join(", "))}]`
];

results.forEach((result, index) => {
svg
.append("text")
.attr("x", 10)
.attr("y", 30 + index * 30)
.attr("font-size", "16px")
.attr("fill", "black")
.text(result);
});

return svg.node();
}
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