Public
Edited
Nov 17, 2022
Insert cell
Insert cell
arr = [2, 4, 5]
Insert cell
arr.map((item, i) => arr[i])
Insert cell
arr.map(function (item, i) {
return arr[i];
})
Insert cell
function addTwo(number) {
return number + 2;
}
Insert cell
arr.map(addTwo)
Insert cell
function pythagorean(a, b) {
return Math.sqrt(a ** 2 + b ** 2);
}
Insert cell
pythagorean(3, 2)
Insert cell
Insert cell
points[1].geometry.coordinates[0]
Insert cell
x_distance = {
const x_coords = points.map((i) => i.geometry.coordinates[0]);
return x_coords[0] - x_coords[1];
}
Insert cell
y_distance = {
const y_coords = points.map((i) => i.geometry.coordinates[1]);
return y_coords[0] - y_coords[1];
}
Insert cell
pythagorean(x_distance, y_distance)
Insert cell
names = FileAttachment("Untitled spreadsheet - Sheet1(1).csv").csv()
Insert cell
function getFirstName(fullName) {
return fullName.split(" ")[0];
}
Insert cell
firstNames = names.map(function (item) {
return getFirstName(item.name);
})
Insert cell
function lessThan5(firstName) {
return firstName.length < 5;
}
Insert cell
firstNames.filter((item) => lessThan5(item))
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more