Published
Edited
Feb 13, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
console.log("Hello world");
// or
var helloMit = "Hello MIT";
console.log(helloMit);
}
Insert cell
Insert cell
// this is a comment
/* this is a miltiline comment
many lines of comments
*/
Insert cell
Insert cell
Insert cell
height = 500
Insert cell
Insert cell
Insert cell
dimension = ({height, width})
Insert cell
width = 480
Insert cell
Insert cell
// dimension = {1000, 960}
Insert cell
Insert cell
{
let firstNumber = 55
return firstNumber + 10
}
Insert cell
// This block defines a cumulative sum of numbers from 0 to 10
{
let x = 0;
for (let i = 1; i <= 10; ++i) {
x += i;
}
return x;
}
Insert cell
Insert cell
x
Insert cell
Insert cell
function running_total(max) {
let x = 0;
for (let i = 1; i <= max; ++i)
x += i;
return x;
}
Insert cell
function addingNumbers(number3, number4){
return number3 + number4
}
Insert cell
addingNumbers(4,50)
Insert cell
Insert cell
running_total(10)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const a = 5;
a = 6;
return a;
}
Insert cell
{
let myFirstVar = 'hello'
const myConstantVar = 'world'
return myFirstVar
// myConstantVar = "hi"
}
Insert cell
Insert cell
{
let a = 5;
a = 6
return a;
}
Insert cell
Insert cell
Insert cell
1 + 2
Insert cell
typeof (1 + 2)
Insert cell
1.0 + 2.5
Insert cell
typeof (1.0 + 2.5)
Insert cell
2 / 0
Insert cell
typeof (2 / 0)
Insert cell
"a" / 2
Insert cell
typeof ("a" / 2)
Insert cell
Insert cell
"hello, world"
Insert cell
typeof "hello, world"
Insert cell
"hello, " + "world"
Insert cell
name = "" // Fill your name in here!
Insert cell
`hello, world, it's ${name}`
Insert cell
typeof (`hello, world, it's ${name}`)
Insert cell
`today is ${day}`
Insert cell
day = "Friday"

Insert cell
Insert cell
9 > 10
Insert cell
typeof (9 > 10)
Insert cell
10 == 10
Insert cell
Insert cell
(9 > 10) && (10 == 10) // Evaluates to false AND true
Insert cell
(9 > 10) || (10 == 10) // Evaluates to false OR true
Insert cell
!(9 > 10) && (10 == 10) // Evaluates to NOT(false) AND true
Insert cell
!((9 > 10) || (10 == 10)) // Evaluates to NOT(false or true)
Insert cell
Insert cell
Insert cell
typeof (x)
Insert cell
Insert cell
{ let y = 1
return typeof (y)
}
Insert cell
Insert cell
ra = ["one", 2, 3.0]
Insert cell
typeof ra
Insert cell
ra[0]
Insert cell
ra[3]
Insert cell
Insert cell
function addthese(a, b) {
return a+b;
}
Insert cell
typeof(addthese)
Insert cell
typeof(addthese(1, 4))
Insert cell
Insert cell
Insert cell
margin = ({top : 500, bottom : 300 })
Insert cell
car = ({
make: 'Fiat',
model : 500
})
Insert cell
car.model
Insert cell
Insert cell
Insert cell
"hello, world".toUpperCase()
Insert cell
Insert cell
directory = {
const data = {"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]};
return data
}
Insert cell
directory.employees
Insert cell
directory.employees[1]
Insert cell
directory.employees[1].firstName
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