Week 5 exercises
This commit is contained in:
parent
40cbdfff58
commit
93738938d7
1402
w5_HOF/data.js
Normal file
1402
w5_HOF/data.js
Normal file
File diff suppressed because it is too large
Load Diff
48
w5_HOF/index.html
Normal file
48
w5_HOF/index.html
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css" />
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<ol class="smallText">
|
||||||
|
<li>
|
||||||
|
<p>Get the list of people with age > 21. How many are there?</p>
|
||||||
|
<p class="result" id="q1">TODO</p>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Get the total and average income for the entire population.
|
||||||
|
</p>
|
||||||
|
<p class="result" id="q2">TODO</p>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Get total and average income of people older than 21 (included).</p>
|
||||||
|
<p class="result" id="q3">TODO</p>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Find in which city “Mitsue Tollner” lives.</p>
|
||||||
|
<p class="result" id="q4">TODO</p>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Find if there is anyone who lives in the same city of others.</p>
|
||||||
|
<p class="result" id="q5">TODO</p>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>Get the city/cities where most people live.</p>
|
||||||
|
<p class="result" id="q6">TODO</p>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<script defer type="module" src="sketch.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
35
w5_HOF/sketch.js
Normal file
35
w5_HOF/sketch.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
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';
|
||||||
|
}
|
11
w5_HOF/style.css
Normal file
11
w5_HOF/style.css
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
body {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ol {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result {
|
||||||
|
color: red;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user