Published
Edited
Feb 14, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function sum(a, b) {
return a+b
}
Insert cell
function mult(a, b) {
return a*b
}
Insert cell
function execFunction (func, a, b) {
return func(a,b)
}
Insert cell
execFunction(mult, 5, 2)
Insert cell
function retFunction(func1, func2, selector) {
if(selector)
return func1
else
return func2
}
Insert cell
retFunction(sum,mult,true)(5,10)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getDog(animal) {
if(animal.species==='dog')
return true
return false
}
Insert cell
function getCat(animal) {
if(animal.species==='cat' || animal.species==='kitty')
return true
return false
}
Insert cell
Insert cell
animalArray.filter(getDog)
Insert cell
animalArray.filter(getCat)
Insert cell
Insert cell
Insert cell
Insert cell
function countCats( currentCount, animal) {
if(animal.species==='cat'||animal.species==='kitty')
return currentCount + 1
return currentCount
}
Insert cell
animalArray.reduce(countCats, 0)
Insert cell
Insert cell
Insert cell
Insert cell
function getAnimalName(animal) {
return animal.name
}
Insert cell
animalArray.map(getAnimalName)
Insert cell
Insert cell
Insert cell
kittyArray = ['bob', 'sammy', 'hello', 'sammy', 'just a kitty', 'super kitty', 'mr. butters']
Insert cell
Insert cell
function toName( inputArray ) {
//Code Here
}
Insert cell
Insert cell
Insert cell
function toObject( inputArray ) {
//Code Here
}
Insert cell
Insert cell
Insert cell
function toCart( foodArray ) {
//Code Here
}
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