Public
Edited
Aug 28, 2024
Insert cell
Insert cell
Insert cell
paragraph = "Since its founding in 1831, NYU has been an innovator in higher education, reaching out to an emerging middle class, embracing an urban identity and professional focus, and promoting a global vision that informs its 20 schools and colleges."
Insert cell
paragraph.length
Insert cell
Insert cell
words = paragraph.split(' ')
Insert cell
Insert cell
words.length
Insert cell
Insert cell
words[1]
Insert cell
Insert cell
new Set(words).size
Insert cell
Insert cell
prices = ({
milk: 3.45,
crackers: 4.54,
pepsi: 1.00,
chips: 2.98,
})
Insert cell
prices.milk
Insert cell
prices["milk"]
Insert cell
Insert cell
food = "chips"
Insert cell
prices[food]
Insert cell
Insert cell
prices
Insert cell
Insert cell
[
["milk", 3.45],
["crackers", 4.54],
["pepsi", 1.00],
["chips", 2.98]
]
Insert cell
kvps = Object.entries(prices)
Insert cell
Insert cell
Object.fromEntries(kvps)
Insert cell
Insert cell
items = new Map(kvps)
Insert cell
Insert cell
items.get("milk")
Insert cell
Insert cell
snack = "chips"
Insert cell
items.get(snack)
Insert cell
Insert cell
Array.from(items.keys())
Insert cell
[...items.keys()]
Insert cell
Insert cell
items
Insert cell
Array.from(items)
Insert cell
Insert cell
Array.from(items, ([item, cost]) => ({item, cost}))
Insert cell
Array.from(items, function (pair){
return {
item: pair[0],
cost: pair[1]
}
})
Insert cell
Insert cell
function triangleArea(base, height) {
return base * height / 2;
}
Insert cell
triangleArea(10, 20)
Insert cell
triangleArea2 = (base, height) => base * height / 2
Insert cell
triangleArea2(10, 20)
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