Public
Edited
Feb 18, 2023
Insert cell
Insert cell
Insert cell
2
Insert cell
Insert cell
.5 // type a floating point here
Insert cell
Insert cell
10000000000000000000000000
Insert cell
Insert cell
13 % 5
Insert cell
Insert cell
3+2==4
Insert cell
Insert cell
5 < 4
Insert cell
Insert cell
5 > 4 && 5 > 3
Insert cell
false || true
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
myName.toUpperCase()
Insert cell
Insert cell
Insert cell
`$My name is ${myName}, and I am ${20 + 20} years old`
Insert cell
Insert cell
md `
1. item 1
1. item 2
1. item 3
`
Insert cell
Insert cell
Insert cell
md `# it's heading`
Insert cell
md `## it's heading`
Insert cell
md `### it's heading`
Insert cell
md `#### it's heading`
Insert cell
Insert cell
myName.length
Insert cell
Insert cell
Insert cell
Insert cell
array = ['a', 'b', 'c']
Insert cell
Insert cell
array[2]
Insert cell
Insert cell
Insert cell
// now slice from the right
array.slice(1)
Insert cell
// now slice from both sides
Insert cell
// turn an array into a string?
Insert cell
'I put my thing down and split 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
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
data_city = [
{year: 2005, Continents: "Africa",undernourishedP:189.9 },
{year: 2005, Continents: "Asia",undernourishedP:552.5 },
{year: 2005, Continents: "Latin America and the caribbean",undernourishedP:51.7 },
{year: 2005, Continents: "Oceania",undernourishedP:2.3 }
]
Insert cell
data_city
Type Table, then Shift-Enter. Ctrl-space for more options.

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
percentChange(80,20)
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
Insert cell
precip (data[2])
Insert cell
city_C = d=>d.undernourishedP
Insert cell
city_C(data_city[2])
Insert cell
Insert cell
d3=require('d3-array')
Insert cell
d3.mean(data, d=>d.annual_precipitation)
Insert cell
d3.mean(data_city, d=>d.undernourishedP)
Insert cell
d3.min(data, d => d.annual_precipitation)
Insert cell
d3.min(data_city, d=>d.undernourishedP)
Insert cell
d3.max(data, d => d.annual_precipitation)
Insert cell
d3.max(data_city, d=>d.undernourishedP)
Insert cell
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
Insert cell
printTable(data)
Insert cell
printTable(data_city)
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more