Published
Edited
Oct 12, 2022
"Row" of AA data
In class exercises for 10/5
Insert cell
# In class exercises for 10/5
Insert cell
Insert cell
x = ["a", "a", "b", "b", "b", "c", "c", "C", "c"]
Insert cell
x.includes("a")
Insert cell
x.includes("b")
Insert cell
x.includes("c")
Insert cell
x.includes("C")
Insert cell
x.includes("a", "a", "b", "b", "b", "c", "c", "C", "c")
Insert cell
x.includes("d")

Insert cell
Insert cell
x.length
Insert cell
Insert cell
x[5]
Insert cell
Insert cell
// another way to do it

function separatedata(Z) {
var string = []
for(let i=0; i<Z.length ; i++){
if (string.includes(Z[i])=== false){
string.push(Z[i])
}
}
return string
}
Insert cell
separatedata(x)
Insert cell
// unique = (value, index, self) => {
// return self.indexOf(value) === index
// }
Insert cell
// x.filter(unique)
Insert cell
Insert cell
letterNumber = ({
a: 1,
b: 2,
c: 3,
C: 4
})
Insert cell
mergedvariable = [separatedata(x),letterNumber,]
Insert cell
function MergerFunction (original, merged) { // original=x array and merged= letterNumber
var newArray = []; // name you want to give the new array
for (let index = 0; index < original.length; ++index) { //loop that will address each line of the array
newArray.push(({name: original[index], number:merged[original[index]]}))
}
return newArray
}
Insert cell
MergerFunction(x, letterNumber)
Insert cell
Insert cell
Insert cell
latLongs = [({address: "2 W 13th St, New York, NY 10011", latLong: [40.735439, -73.994728]}), ({address: "1000 5th Ave, New York, NY 10028", latLong: [40.779079, -73.962578]}), ({address: "55 W 13th St, New York, NY 10011", latLong: [40.736561, -73.996460]})]
Insert cell
latLongs[0]['address']
Insert cell
latLongs.length
Insert cell
function coordinatesAddingHandler(addresses, latLongs){
let finalAddress = []
for(let i = 0; i<address.length; i++){
for(let j=0; j<latLongs.length; j++){
if(address[i] === latLongs[j]['address']){
finalAddress.push({'address': address[i], 'latlng':latLongs[j]['latLong'] })
}
}
}
return finalAddress
}
Insert cell
coordinatesAddingHandler(address,latLongs)
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