Public
Edited
Sep 28, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
resuableVar = {
var observableVar = "c"
observableVar = 3
var observableVar = "d"
observableVar = 4
return observableVar
}
Insert cell
resuableVar * 10
Insert cell
Insert cell
{
let observableLet = "a"
observableLet = 1
let observableLet = "e"
observableLet = 7
}

Insert cell
Insert cell
{
const observableConst = "b"^
observableConst = 2
}
Insert cell
Insert cell
Insert cell
intArray = [1,2,3]

Insert cell
intArray
Insert cell
strArray = ["The", "quick", "brown", "fox", "jumped", "over", "the", "old", "brown", "fence"]
Insert cell
mixedArray = [10, "quick", "brown", "foxes"]
Insert cell
Insert cell
mixedArray.push('jump')

Insert cell
mixedArray
Insert cell
Insert cell
Insert cell
setElement = new Set(["The", "old", "brown", "fox", "jumped", "over", "the", "old", "brown", "fence"])
Insert cell
Insert cell
emptyObject = {}
Insert cell
Insert cell
emptyObservableObject = ({})
Insert cell
Insert cell
emptyObservableObject.test = 3
Insert cell
emptyObservableObject.test * 10
Insert cell
Insert cell
Insert cell
Insert cell
{
const numbers = [1,2,3,4,5,6]
return numbers.map((x) => x**2)
}
Insert cell
Insert cell
coordinate = {
const xPos = [1,2,3,4,5,6,7,8,9]
const yPos = [9,8,7,6,5,4,3,2,1]

return xPos.map((k,i) => ({x: k, y:yPos[i]}))
}
Insert cell
Insert cell
x5 = coordinate.filter((coord) => coord.x == 5)
Insert cell
Insert cell
avgX = {

return coordinate.reduce((acc, curr) => {
return acc + curr.x}, 0)/coordinate.length
}
Insert cell
Insert cell
Insert cell
dna = 'atgtcgcccggtctaactggaacgttacaaaacacacgccgtttcgtaactaaaagagtgatgcaccagaacatcgaatttacttacgttgacccaactgagagcttggcccagttagcatcccgtaagaatgtccttaaacggtctaaagcgagtgaccgagtgctgttcgccaattggtcccggctgagggacaccgcttgtggggcctcaatattaactaactgtgctctcgttgcctgtggggacaactgtgagatagaacctgcgtacaggtgtaagcaactcacttccctatgcgggtcgttcataggaacacactcagcgacaataaatttccgtaacccggaggcgcctattaggtgggcgggtaaggctacagcaccaacgatgattaactttactccaccagcaaacatagattatgtagtagcagcatttgagacgggactcttgctcgcgcgcgttggtcactttctcaggttagatagccctactagccgctcggtagctttgggttcgggtgacatcccagccatcgacccagttcagctccaggggcggttccgtattatccccaggctcgtgccattattgatatgcgctctcgtagtatctaacaacgtggcgagcgacaccaatggcagcacgaagagattatattgtagggtgggtagggatcggcggacagcgtgcactgctacggatgtaattcctttagacgtaggcgcactgcctaccagtgccaaggtttcctctggcagcgccttgtattgttctcgcatatgcatatccttgttttttcattgcctcggaaaccacaaaccaaaatacatagaccaccttgacacatatcccagagctcaccgttcgggagtctctaccgtaatgttattgatgaatatagtgcccaggtactcggaagtataccacatatgtggaattttcgctacaggtggccggcagcgttcgtggataaccttgggggcctaccaatgcctgtcacagccgtcaaggtgtcgtctggttgtgggtaacgcgcatatataa'
Insert cell
dnaLength = dna.length
Insert cell
Insert cell
// answer
codons = {
let tempCodons = []
for (let i = 0; i<dnaLength; i = i + 3){
tempCodons.push(dna.substring(i,i+3))
}
return tempCodons
}
Insert cell
Insert cell
// answer
uniqCodons = new Set(codons)
Insert cell
Insert cell
"act".toUpperCase()
Insert cell
Insert cell
// answer
codons.map(x=> dnaToAA[x.toUpperCase()])

Insert cell
Insert cell
dnaAsArray = dna.toUpperCase().split("")
Insert cell
function computeGC( accumulator, currentChar) {
// complete this function
if (currentChar === "C" | currentChar === "G")
return accumulator+1
else
return accumulator
}
Insert cell
gcOfSequence = dnaAsArray.reduce(computeGC, 0) / dnaAsArray.length
Insert cell
Insert cell
Insert cell
species = "saureus"
Insert cell
// answer
organisms[species]

Insert cell
Insert cell
Insert cell
Insert cell
function triangleArea(base, height) {
return base * height / 2;
}
Insert cell
triangleArea(10, 20)
Insert cell
// answer
triangleAreaArrow = (base, height) => base * height / 2;
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