Published
Edited
Apr 22, 2018
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
my_array = [13, 15, 17, 19, 19, 21]
Insert cell
my_array[0]
Insert cell
my_array.slice(0, 3)
Insert cell
my_array.indexOf(19)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
my_expense = ({
"cost": 44,
"category": "wine",
"comment": "wasnt good, too expensive"
})
Insert cell
my_expense['category']
Insert cell
my_expense['additional_comment'] = "Actually, the wine wasnt that bad, it was bad company"
Insert cell
delete my_expense['additional_comment']
Insert cell
my_expense.cost
Insert cell
Insert cell
Insert cell
Insert cell
frankenstein_array = [42, "errol", Math.random(), [1, 2, 3, 4]]
Insert cell
dr_frankenstein = ({
phd: "I forgot",
monster: frankenstein_array
})
Insert cell
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Insert cell
matrix[1][1]
Insert cell
Insert cell
my_expenses = [

{cost: 44, cat: 'wine', comment: 'what'},
{cost: 12, cat: 'kebab', comment: 'was'},
{cost: 130, cat: 'guitar', comment: 'that'}

]
Insert cell
table(my_expenses, {sortable: true})
Insert cell
Insert cell
Insert cell
my_other_expenses = {

var exp1 = {
category: 'food',
cost: 18.4,
comment: 'expensive'
}
var exp2 = {
category: 'petrol',
cost: 64.2,
comment: 'Need bicycle'
}
var expenses = [exp1, exp2]
expenses.push(
{
category: 'alcohol',
cost: 28.5,
comment: 'what are you looking at?!!'
}
)
return expenses
}
Insert cell
Insert cell
{
my_other_expenses[1]['additional_comment'] = "too lazy for bicycle"
return my_other_expenses
}
Insert cell
Insert cell
Insert cell
Insert cell
{

var my_data = [13, 15, 17, 19]
var new_data = []
my_data.forEach( function(element_of_the_array){
var new_element = element_of_the_array * element_of_the_array
new_data.push(new_element)
})
return new_data

}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{

var my_data = [13, 15, 17, 19]
var square_data = my_data.map( function(single_element){
return single_element * single_element
})
return square_data


}
Insert cell
Insert cell
Insert cell
Insert cell
// A boolean statement - the kind necessary for filter functions
10 > 70
Insert cell
{

var my_data = [13, 15, 17, 19, 25, 27, 31, 47, 55]
var small_data = my_data
.filter(function(element){
return (element > 15) && (element < 47)
})
return small_data

}
Insert cell
Insert cell
{

var my_data = [13, 15, 17, 19, 25, 27, 31, 47, 55]
var small_data = my_data
.filter(function(element){
return (element > 15) && (element < 47)
})
.map(function(element){
return element * element
})
.filter(function(element){
return element < 700
})
return small_data

}
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