Public
Edited
Feb 26, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function percapita(variable, total_population) {
return ; // TODO: update this to return the result of the // Per capita function
function percapita(variable, total_population) {
return (variable / total_population) * 100000;
}

// Test per capita function
console.log(percapita(25000, 50000)); // Output should be 5000

Insert cell
Insert cell
percapita(50, 100)
// Per capita function
function percapita(variable, total_population) {
return (variable / total_population) * 100000;
}

// Test per capita function
console.log(percapita(25000, 50000)); // Output should be 50000


Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{// function percapita(variable, total_population) {
return (variable / total_population) * 100000;
}
Per capita function
function percapita(variable, total_population) {
return (variable / total_population) * 100000;
}

// Test per capita function
console.log(percapita(25000, 50000)); // Output should be 50000

let highest_pop = 0;
let lowest_pop = 1000000;
let highest_row, lowest_row;
for (let row of data) {
// Update this if statement to apply to any row with a greater population than the
// previously seen highest population
if (???) {
highest_pop = row.population; // save new highest pop
highest_row = row; // save row
}

// Update this if statement to apply to any row with a lesser population than the
// previously seen lowest population
if (???) {
lowest_pop = row.population; // save new lowest pop
lowest_row = row; // save row
}
}

return {highest_row, lowest_// Per capita function
function percapita(variable, total_population) {
return (variable / total_population) * 100000;
}

// Test per capita function
console.log(percapita(25000, 50000)); // Output should be 50000

Insert cell
Insert cell
{
for (let row of data) {
let targetCounty = "Palm Beach";
let targetDate = "2020-04-09";
// Finish this if statement to find the correct piece of data.
// Replace ??? with the correct property key to solve the question.
if (row.??? === targetCounty && row.??? === targetDate) {
return row;
}
}
}
Insert cell
Insert cell
{
for (let row of data) {
// Use the example for the second question as a template to solve this problem
// and return the correct row
}
}
Insert cell
Insert cell
{
for (let row of data) {
// Use the example for the first question as a template to solve this question
}
}
Insert cell
Insert cell
{
// This is a two-parter. First we need to filter to just a list of counties
// With the appropriate population
let filteredCounties = []
for (let row of data) {
// Update this to also check if the row has a lower population than 50,000
if (row.population >= 20000) {
// Check if the date is correct
if (row.date === "2020-09-22") {
filteredCounties.push(row)
}
}
}

// Now we loop over the filtered list to find the correct row
// (You don't need to change anything here if you filtered the list correctly above)
let most_new_cases = 0;
let most_new_cases_row;
for (let row of filteredCounties) {
if (row.new_cases_per_cap > most_new_cases) {
most_new_cases = row.new_cases_per_cap;
most_new_cases_row = row
}
}
return most_new_cases_row
}
Insert cell
Insert cell
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