Published
Edited
Dec 4, 2020
42 forks
39 stars
Insert cell
Insert cell
Insert cell
Insert cell
function getDate() {
return new Date().toDateString();
}
Insert cell
Insert cell
Insert cell
Insert cell
function getWorkshopDate () {
return new Date(2020, 11, 4).toDateString();
}
Insert cell
Insert cell
Insert cell
Insert cell
function toHex(n) {
let hex = n.toString(16);
return hex.padStart(2, '0');
}
Insert cell
Insert cell
Insert cell
Insert cell
function rgbToHex(R, G, B) {
return '#' + [toHex(R), toHex(G), toHex(B)].join('');
}
Insert cell
Insert cell
Insert cell
Insert cell
function setColor(R, G, B) {
const hex = rgbToHex(R, G, B);
const colorMe = document.getElementById('color-me');
colorMe.setAttribute('style', 'color: ' + hex);
}
Insert cell
Insert cell
Insert cell
Insert cell
async function readJsonFile(filename) {
const file = await fetch(
'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojson'
);
return await file.json();
}
Insert cell
Insert cell
Insert cell
Insert cell
function writeJsonString(object) {
return JSON.stringify(object, null, 2);
}
Insert cell
Insert cell
Insert cell
Insert cell
function exclusiveOr(A, B) {
return (A || B) && !(A && B);
}
Insert cell
Insert cell
Insert cell
Insert cell
function computeTruthTable(operator) {
const truthValues = [true, false];
const table = [];
for (const A of truthValues) {
for (const B of truthValues) {
const value = operator(A, B);
table.push({ A, B, value });
}
}
return table;
}
Insert cell
Insert cell
Insert cell
Insert cell
function showTruthTable(operator) {
console.table(computeTruthTable(operator));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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