Blocks are like functions, but they run immediately and don’t have parameters. Just like before, when you move the slider, the value of total is automatically recomputed
`
d3=require('d3@5')// will make all of d3.js available
ss=require('simple-statistics')// can do simple statistics with this
prods=ss.sum([1,2,3])*ss.min([4,7,9]);
md`${prods}`
state={
letx=5;
lety="";
if(x>1){
y="x is greater than 1"
}
returny;
}
cel2fahr=
((f-32)/9)*5;
f=32
someblock={
return{
x:ss.sum([1,2,3]),
y:ss.mean([1,2,3])
}
}
// You can create a block and a cell as a literal object this way
someblock.x/someblock.y
functioncels2fahr(cels){
letfahr=(cels/5)*9+32
returnfahr;
}
// you can create functions and call the function everywhere
cels2fahr(0)
dict=({
x:1,
y:2
})
// create an object literal, you can even create small data sets this way
dict.x+dict.y// then do whatever you want to do in another cell
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.