function exploreDigitalDivide()
{
// Select what data to display
const metric = prompt(
"Which digital divide metric would you like to explore?\n" +
"1: Income-based internet access\n" +
"2: Urban vs rural access\n" +
"3: Age-based internet usage\n" +
"4: Global connectivity rates"
);
// Sample data
const incomeData = {
categories: ["Lowest 20%", "Second 20%", "Middle 20%", "Fourth 20%", "Highest 20%"],
values: [62, 71, 80, 88, 95]
};
const locationData = {
categories: ["Urban", "Rural"],
values: [94, 83]
};
const ageData = {
categories: ["18-29", "30-49", "50-64", "65+"],
values: [97, 93, 88, 61]
};
const globalData = {
categories: ["North America", "Europe", "Asia Pacific", "Latin America", "Middle East/Africa"],
values: [90, 87, 54, 68, 40]
};
// Select dataset based on user choice
let data;
let title;
switch(metric) {
case "1":
data = incomeData;
title = "Internet Access by Income Level (%)";
break;
case "2":
data = locationData;
title = "Urban vs Rural Internet Access (%)";
break;
case "3":
data = ageData;
title = "Internet Usage by Age Group (%)";
break;
case "4":
data = globalData;
title = "Internet Access by Region (%)";
break;
default:
alert("Invalid selection!");
return;
}
// Display the data (in a real app, this would create a chart)
console.log(title);
console.log("=".repeat(title.length));
const maxValue = Math.max(...data.values);
const maxBarLength = 40;
for (let i = 0; i < data.categories.length; i++) {
const barLength = Math.round((data.values[i] / maxValue) * maxBarLength);
const bar = "█".repeat(barLength);
console.log(`${data.categories[i].padEnd(12)}: ${bar} ${data.values[i]}%`);
}
}
exploreDigitalDivide();