forked from johntango/BostonCity
-
Notifications
You must be signed in to change notification settings - Fork 30
/
indexBoston.html
35 lines (32 loc) · 975 Bytes
/
indexBoston.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<link rel="stylesheet" href="./mystyles.css">
<script>
// data[8] is the name, data[18] is salary
let url = "https://pollysnips.s3.amazonaws.com/bostonEmployeeSalaries.json"
fetch(url).then((response) => response.json())
.then(json => {
data = json;
analyzeData(data);
})
.catch(error => {
throw(error);
})
function analyzeData(data){
// get max salary
let maxSalary = {name:"", salary:0};
data.data.forEach((item)=>{
if(parseInt(item[18])>=maxSalary.salary){
maxSalary.name = item[8]
maxSalary.salary = parseInt(item[18])
}
})
writeData(maxSalary)
}
function writeData(data){
document.getElementById("data").innerHTML += "<h1>"+JSON.stringify(data)+"</h1> <br>";
}
</script>
<body>
<h1>Hello Boston City Most Valued Worker</h1>
<div id="data">
</div>
</body>