Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.
{
letmyList=[]
myList.push(3+8*4-7)
myList.push(4+8)
returnmyList
}
{
letcount=1
letnumList=[]
count=count+1
numList.push(count)
count=count+1
numList.push(count)
count=count+1
numList.push(count)
returnnumList
}
{
letcount=1
letnumList=[]
count++
numList.push(count)
count++
numList.push(count)
count++
numList.push(count)
returnnumList
}
{
letnumList=[];
for(letcount=2;count<=4;count++)
{
numList.push(count)
}
returnnumList
}
Math.random()
Math.floor(Math.random()*10)
functionmyRandom(upperLimit)
{
returnMath.floor(Math.random()*(upperLimit+1))
}
myRandom(100)
points={
letmyArray=[]
for(letcount=0;count<100;count++)
{
myArray.push(myRandom(100))
}
returnmyArray
}
{
constcontext=DOM.context2d(width,10)
context.rect(5,5,1,1)
context.stroke()
returncontext.canvas
}
{
constcontext=DOM.context2d(100,100)
for(letxIndex=0;xIndex<points.length;xIndex+=2)
{
context.rect(points[xIndex],points[xIndex+1],1,1)
context.stroke()
}
returncontext.canvas
}
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.