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

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