Public
Edited
May 9, 2024
Insert cell
Insert cell
html`<textarea style="width: 80%; height: 30em">${JSON.stringify(
questions,
null,
2
)}</textarea>`
Insert cell
questions = chunks
.map((s) => {
const lines = s.split(/\n/g);
return lines;
})
.map((lines) => {
function clean(q) {
return q.split(" ").splice(1).join(" ");
}
const title = lines[0];
let ref = null;
if (title.includes("[")) {
ref = title.split(/\[/)[1].split(/\]/)[0];
}
const code = title.split(" ")[0];
const answer = title.split(" ")[1].replace("(", "").replace(")", "");
return {
code: code,
question: lines[1],
answer: answer.toLowerCase(),
ref: ref,
a: clean(lines[2]),
b: clean(lines[3]),
c: clean(lines[4]),
d: clean(lines[5])
};
})
Insert cell
chunks = raw.split("~~\n\n")
Insert cell
raw = fetch(
"https://gist.githubusercontent.com/simonw/73e1a740a0671d48f83cdee4bff4f3f1/raw/29afcbc3ca86389402b9afefee0cd7f88ea70ed8/ham-general.txt"
).then((r) => r.text())
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