Published
Edited
Aug 27, 2021
2 forks
13 stars
Insert cell
Insert cell
35 + 7
Insert cell
Insert cell
"Hello, world!"
Insert cell
Insert cell
myName = "Ben"
Insert cell
Insert cell
myEuroShoeSize = 4 * (10 + 1)
Insert cell
Insert cell
`My name is ${myName} and my shoes are size ${myEuroShoeSize}, which is the only way to measure feet.`
Insert cell
Insert cell
Insert cell
Insert cell
4 > 5
Insert cell
0 == (10 - 5 - 5)
Insert cell
Insert cell
myList = [1,2,4, myName, myEuroShoeSize, "hello", false, "...one last thing"]
Insert cell
Insert cell
[]
Insert cell
Insert cell
Insert cell
myObject = ({animalType:"dog", petName:"Patch", isGood:true, legs:4})
Insert cell
Insert cell
myList[3]
Insert cell
Insert cell
myList[0]
Insert cell
Insert cell
myObject["animalType"]
Insert cell
Insert cell
myList[myObject["legs"]]
Insert cell
Insert cell
function greet(name){
return `Hello ${name}`
}
Insert cell
greet("Kermit the Frog")
Insert cell
Insert cell
myList.map(greet)
Insert cell
Insert cell
# The anatomy of functions

We talked about functions at the end of the previous session, but I left so much unsaid.
Insert cell
function theNameOfTheFunction(argument1, argument2){
const result = argument1 + argument2
return result
}
Insert cell
Insert cell
theNameOfTheFunction(10, 15)
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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