Notebooks 2.0 is here.

Public
Edited
Feb 14, 2024
Insert cell
Insert cell
Insert cell
//variable x= number 23
x = 23
Insert cell
// Define y as string
y = "Inxd"
Insert cell
//For multi-line strings- Backtick (``) the key below the esc key on keyboard
long_line = `We are learning Javascript,
and its only the first day`
// Use \ (backslash) to enter a new line
Insert cell
// Boolean is True or False
bool_var = "True"
Insert cell
//Date
today = Date("14/02/202")
// or can use today = new Date(1707903741200). toString() to generate the same output
Insert cell
Date.now()
Insert cell
Insert cell
function f(x) {
return x+1;
}
// in place of the abvove formula we can write this also.. function f(x) {
// var y = x+1;
// return y; }
Insert cell
function sum(a,b) {
return a+b;
}
Insert cell
sum(2,4)
Insert cell
sum("hello", "world")
Insert cell
Insert cell
sumshort= (a,b) => a+b
Insert cell
(a,b) => a+b
Insert cell
Insert cell
Insert cell
prime = [2,3,5,7,11,13]
Insert cell
prime[0]
Insert cell
prime[3]
Insert cell
prime[5]
Insert cell
prime1= [2,3,"helloo",5,7,11]
Insert cell
prime1[2]
Insert cell
Insert cell
shortNames = ({
india: "IN",
china: "CN",
russia: "RU"
})
Insert cell
shortNames.india
Insert cell
shortNames["india"]
//similar to array
Insert cell
Insert cell
// csv data
sample = `area, sale, profit
north,5,2
south,10,4
east,15,6
west,20,8
central,25,10`
Insert cell
data = d3.csvParse(sample, d3.autotype)
Insert cell
Insert cell
sampleCol =({
})
Insert cell
Insert cell
Plot.plot()
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