Published
Edited
Oct 8, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
x = ["a", "a", "b", "b", "b", "c", "c", "C", "c"]
Insert cell
x.length
Insert cell
x.includes("a")
Insert cell
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
Insert cell
letterNumber = ({
a: 1,
b: 2,
c: 3,
C: 4
})
Insert cell
function MergerFunction (ori, mer) { //ori= x array and mer= letterNumber
var newArray = []; //name you want to give the new array
for (let index = 0; index < ori.length; ++index) { //loop that will address each line of the array
newArray.push(({name: ori[index], number: mer[ori[index]]}))
}
return newArray
}
Insert cell
MergerFunction(x, letterNumber)
Insert cell
Insert cell
addresses = ["2 W 13th St, New York, NY 10011", "55 W 13th St, New York, NY 10011", "1000 5th Ave, New York, NY 10028", "2 W 13th St, New York, NY 10011", "2 W 13th St, New York, NY 10011"]
Insert cell
addresses.length
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.length
Insert cell
function coordinatesAddingHandler(addresses, latLongs){
let finalAddresses = []
for(let i = 0; i<addresses.length; i++){
for(let j=0; j<latLongs.length; j++){
if(addresses[i] === latLongs[j]['address']){
finalAddresses.push({'address': addresses[i], 'latlng':latLongs[j]['latLong'] })
}
}
}
return finalAddresses
}
Insert cell
coordinatesAddingHandler(addresses,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