Published
Edited
Jun 23, 2020
2 forks
2 stars
Insert cell
Insert cell
Insert cell
2
Insert cell
Insert cell
.5 // type a floating point here
Insert cell
Insert cell
1e+21
Insert cell
Insert cell
13 % 5
Insert cell
Insert cell
false
Insert cell
Insert cell
5 < 4
Insert cell
Insert cell
5 > 4 && 5 > 3
Insert cell
Insert cell
'James'
Insert cell
Insert cell
myName = 'James' + ' Gordon'
Insert cell
Insert cell
myName.length
Insert cell
Insert cell
myName.toLowerCase()
Insert cell
Insert cell
`$My name is ${myName}, and I am ${20 + 20} years old`
Insert cell
Insert cell
md`
* item 1
* item 2
* item 3
`
Insert cell
Insert cell
html`<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>`
Insert cell
Insert cell
array = ['a', 'b', 'c']
Insert cell
Insert cell
array[2]
Insert cell
Insert cell
// slice from the left
Insert cell
// now slice from the right
Insert cell
// now slice from both sides
Insert cell
// turn an array into a string
Insert cell
'I put my thing down and split it and reverse it'.split('').reverse().join('')
Insert cell
Insert cell
object = ({key1: 'value1', key2: 'value2', key3: 3})
Insert cell
Insert cell
Insert cell
Object.values(object)
Insert cell
data = [
{city: "Seattle", annual_hours_sunshine: 2163, annual_precipitation: 37.13},
{city: "New York", annual_hours_sunshine: 2677, annual_precipitation: 46.23},
{city: "Chicago", annual_hours_sunshine: 2504, annual_precipitation: 39.04},
]
Insert cell
Insert cell
// define a block here
Insert cell
Insert cell
Insert cell
function percentChange(n, o) {
return ((n - o) / o) * 100
}
Insert cell
Insert cell
percentChange(100, 50)
Insert cell
Insert cell
percentChangeArrow = (n, o) => ((n - o) / o) * 100
Insert cell
percentChangeArrow(100, 50)
Insert cell
precip = d => d.annual_precipitation
Insert cell
precip(data[2])
Insert cell
Insert cell
d3 = require('d3-array')
Insert cell
d3.mean(data, d => d.annual_precipitation)
Insert cell
d3.min(data, d => d.annual_precipitation)
Insert cell
d3.max(data, d => d.annual_precipitation)
Insert cell
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
printTable(data)
Insert cell
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