Public
Edited
Nov 6, 2022
Importers
Insert cell
Insert cell
// array of numbers 1 through n
getNaturalNumbers = n => [...new Array(n)].map((v,i)=>i+1)
Insert cell
getNaturalNumbers(10)
Insert cell
// Grab a random subset from a given array
// Not particularly efficient/scalable since it shuffles the entire array ¯\_(ツ)_/¯
randomSample = (arr, n) => d3.shuffle(arr).slice(0, n)
Insert cell
randomSample([11,12,13,14,15,16,17], 2)
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