Files
exercises/w5_1_HOF/index.js
Andrea Bianchi baa0d8559f w_5_1 HOF
2026-03-25 22:18:37 +09:00

40 lines
1.2 KiB
JavaScript

import data from './data.js';
import dataJSON from './data.js'; // this file is a module so we can import
console.log(dataJSON);
// 1. Get the list of people with age > 21. How many are there?
const over21 = undefined;
// setAnswer(1, over21);
// 2. Add a universal basic income of 100 but 500 to Andrea
const updatedData = undefined;
// 3. Get the total and average income for the entire population.
const totIncome = undefined;
const avgIncome = undefined;
// setAnswer(2, `Tot income: ${totIncome}, Average income: ${avgIncome}`);
// 4. Get total and average income of people older than 21 (included).
const totIncome21 = undefined;
const avgIncome21 = undefined;
// setAnswer(3, `Tot income: ${totIncome21}, Average income: ${avgIncome21}`);
// 5. Find in which city “Mitsue Tollner” lives.
const city = undefined;
// setAnswer(4, city);
// 6. Find if there is anyone who lives in the same city of others.
const sameCities = undefined;
// setAnswer(5, sameCities);
// 7. Get the city/cities where most people live.
const mostPopularCity = undefined;
// setAnswer(6, mostPopularCity);
function setAnswer(n, content) {
if (n < 0 || n > 7) return;
const el = document.getElementById(`q${n}`);
el.innerHTML = content;
el.style.color = 'green';
}