Public
Edited
Apr 10
2 forks
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
2 > 1 ? 3 + 4 : 5
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
3 + 4
Insert cell
Insert cell
2 > 1 ? 7 : 5
Insert cell
Insert cell
Insert cell
2 > 1
Insert cell
Insert cell
true
Insert cell
Insert cell
true ? 7 : 5
Insert cell
Insert cell
Insert cell
7
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
a > b
Insert cell
a > b ? a + b : b
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
multiplier_program = (n) => n * 10
Insert cell
Insert cell
Insert cell
Insert cell
multiplier_program(my_number)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
1 + 2
Insert cell
Insert cell
9 % 2 // Also try 8 % 3, or 9 % 0
Insert cell
Insert cell
Insert cell
Insert cell
true
Insert cell
false
Insert cell
true == false // Does true equal false? No it doesn't, that's false
Insert cell
Insert cell
!true
Insert cell
!false
Insert cell
true == !false // Does true equal not false? Yes it does, that's true
Insert cell
Insert cell
Insert cell
"Napoleon" + " " + "Bonaparte"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
"Napoleon".length
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
is_alive = false
Insert cell
Insert cell
Insert cell
2 > 1
Insert cell
2 == 1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
napoleon_birth_year = 1769
Insert cell
napoleon_height = 1.68 // meters as decimal number
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
first_name = "Napoleon"
Insert cell
last_name = "Bonaparte"
Insert cell
Insert cell
Insert cell
full_name = first_name + " " + last_name
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
[1, 2, "Napoleon", -12, "Bonaparte", false]
Insert cell
Insert cell
Insert cell
[
[1, 2, 3],
[4, 5, 6],
[
["a", "b"],
["c", "d"]
]
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
({
first_name: "Napoleon",
last_name: "Bonaparte",
birth_year: 1769
})
Insert cell
Insert cell
Insert cell
Insert cell
[
{
title: "Wannabe",
duration_seconds: 173,
artist: {
name: "Spice Girls"
}
},
{
title: "I Want It That Way",
duration_seconds: 213,
artist: {
name: "Backstreet Boys"
}
}
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
new Date()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
if (current_year - napoleon_birth_year > 50) {
return "red"
} else {
return "green"
}
}
Insert cell
[current_year, napoleon_birth_year, current_year - napoleon_birth_year]
Insert cell
Insert cell
Insert cell
Insert cell
current_year - napoleon_birth_year > 50 ? "red" : "green"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable x = 0
Insert cell
mutable y = 0
Insert cell
Insert cell
Insert cell
function move_to_direction () {
switch (direction) {
case "up":
mutable y += -1
break
case "down":
mutable y += 1
break
case "left":
mutable x += -1
break
case "right":
mutable x += 1
break
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
playlist = ["Quit Playing Games", "Wannabe", "I Want It That Way"]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
playlist.forEach((title) => {
if (title.length > longest_title_length) {
mutable longest_title_length = title.length
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
var numbers = [] // This line creates an empty array

var i = 1
while (i < 10) {
numbers.push(i) // This line pushes the current value if `i` into the list `numbers`
i = i + 1 // This line increases the value of `i`
}

return numbers
}
Insert cell
Insert cell
Insert cell
{
var account_balance = 200

while (account_balance >= 17) {
account_balance = account_balance - 17
}

return account_balance
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const rows = [];

for (let y = 0; y < 10; ++y) {
rows.push([]);

for (let x = 0; x < 10; ++x) {
rows[y].push(x);
}
}

return rows;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
multiplier_program(20)
Insert cell
Insert cell
Insert cell
multiplier_program(1) * multiplier_program(2) * multiplier_program(3)
Insert cell
Insert cell
function power(n) {
var p = 1

for (let i = 0; i < n; i++) {
p = p * n
}

return p
}
Insert cell
power(3)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
power(2)
Insert cell
power(4)
Insert cell
power(power(2))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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