Public
Edited
Oct 19, 2022
1 star
Insert cell
Insert cell
// Get an example list: numbers from 0 to 99.
input1 = Array.from({ length: 100 }, (_, i) => i)
Insert cell
// Now this might be the "max" method
// you'd guess in your implementation
function arrayMax(array) {
return Math.max(...array);
}
Insert cell
// And it seems to work!
arrayMax(input1)
Insert cell
// But let's make a bigger input. A list
// of 200,000 items is nothing that big in the grand scheme
// of things.
input2 = Array.from({ length: 200000 }, (_, i) => i)
Insert cell
// But alas, the naïve implementation ends up being
// too naïve.
arrayMax(input2)
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