Published
Edited
Feb 10, 2020
Insert cell
md`# filtering tutorial`
Insert cell
data = [1,3,56,7,2,4,1,2,4,5,6,7,8,9,9,9,3,2,1,44,5,6,7,8,3,2,1,5,7,8,9]
Insert cell
data.filter(d => d == 4)
Insert cell
data.filter(d => d== 3 || d == 4)
Insert cell
data.filter(d => d > 3 && d <= 6)
Insert cell
data2 = [{x:1,y:3},{x:5,y:7},{x:4,y:4},{x:1,y:8},{x:9,y:3},{x:3,y:6}]
Insert cell
data2.filter(d => d.x == 5)
Insert cell
data2.filter(d => d.x < 7)
Insert cell
data2.filter(d => d.y > 6)
Insert cell
data2.filter(d => d.x == 5 || d.x ==8) // || = or
Insert cell
data2.filter (d=> d.x <= 5 && d.y <=5) // && and
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