Public
Edited
May 22, 2024
1 fork
Insert cell
Insert cell
worksetid = "66477e0b2600006a07132b28";
Insert cell
Insert cell
page_data = fetch(`https://data.htrc.illinois.edu/ef-api/worksets/${worksetid}/volumes`).then((response) => response.json())
Insert cell
Insert cell
agg_data = fetch(`https://data.htrc.illinois.edu/ef-api/worksets/${worksetid}/volumes/aggregated`).then((response) => response.json())
Insert cell
data = agg_data.data
Insert cell
features = data.map(obj => obj.features.body);
Insert cell
function countWordOccurrences(word) {
let count = 0;

// Iterate through each object in the array
for (let obj of features) {
// Iterate through each property in the object
for (let key in obj) {
// Check if the property key contains the word
if (key.includes(word)) {
count += obj[key];
}
}
}

return count;
}
Insert cell
countWordOccurrences("Atreides")
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