36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
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);
|
|
|
|
// 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';
|
|
}
|