Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assignment 2 (andrew) #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
<link rel="stylesheet" href="leaflet.css" />
</head>
<body>
<!--left panel-->
<div style="position:fixed;left:0px;width:400px">
</div>
<!--map-->
<div id="map" style="position:fixed;right:0px;left:400px;height:100%;">
<div id="map" style="position:fixed;right:0px;left:0px;height:100%;">
</div>

<!--javascript imports-->
Expand All @@ -31,6 +28,7 @@
}).addTo(map);
</script>
<script>

/* =====================

# Week 2 - Assignment
Expand Down Expand Up @@ -65,10 +63,39 @@

===================== */

var jsonToCsv = function(json) { console.log(json); };

var data = healthCenters;
var jsonToCsv = function(x){console.log(x)};
/*
var grabpoints = function(x){
var coords = [x.LAT, x.LNG];
var name = x.NAME;
return L.marker(coords).bindPopup(name)}

var points = data.map(grabpoints)
var centers = L.layerGroup(points);

centers.addTo(map)
*/
let trimmed = data.map(function(x){
if (x.ZIP > 19139 && x.ZIP < 19150) {return x}
else {return null}
});

var addMarkers = function(map) {};
trimmed = trimmed.filter(Boolean);

var addMarkers = function(x){
var grabpoints = function(x){
var coords = [x.LAT, x.LNG];
var name = x.NAME;
return L.marker(coords).bindPopup(name)
};

var points = trimmed.map(grabpoints);
var centers = L.layerGroup(points);

centers.addTo(x)
};

/* =====================

Expand All @@ -78,8 +105,9 @@


// `healthCenters` is defined in health_centers.js
jsonToCsv(healthCenters);
jsonToCsv(data);
addMarkers(map);

</script>
<!--Your code ends here-->
</body>
Expand Down
10 changes: 5 additions & 5 deletions lab/lab1/part1-types-variables-math.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@

===================== */

var a;
var a = 50;
var resultTask1 = (a > 30);

var b;
var b = 'string';
var resultTask2 = (typeof b == 'string');

var c;
var c = 1;
var dataTask3 = ['peach', 'plum', 'pear'];
var resultTask3 = ('plum' == dataTask3[c]);

var d;
var d = 'cassiopeia'.length;
var resultTask4 = (d == 'cassiopeia'.length);

var e;
var e = 13;
var resultTask5 = (e%5 == 3);

/* =====================
Expand Down
22 changes: 9 additions & 13 deletions lab/lab1/part2-fizzbuzz.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,17 @@

Believe it or not, this is a common programming challenge in job interviews.

===================== */
===================== */

/* =====================

Start code

===================== */



/* =====================

End code
for (i = 1; i < 101; i = i + 1) {

===================== */
if (i % 3 == 0) {
console.log('Fizz')
}
if (i % 5 == 0 & i % 3 == 0 ) {
console.log('FizzBuzz')
}
}

</script>
</body>
Expand Down
11 changes: 8 additions & 3 deletions lab/lab1/part3-array-access.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@

===================== */

L.marker([0, 0]).addTo(map);
L.marker([0, 0]).addTo(map);
L.marker([0, 0]).addTo(map);
var restaurants = [[39.945030, -75.160599], [39.946149, -75.157954]];
var restaurants = restaurants.concat([[39.950341, -75.165797], [39.950637, -75.168378]]);

console.log(restaurants)

for (i = 0; i < restaurants.length; i = i + 1) {
L.marker(restaurants[i]).addTo(map);
}

/* =====================

Expand Down
6 changes: 5 additions & 1 deletion lab/lab1/part4-data-transformation.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!--left panel-->
<div style="position: absolute; left: 0px; width: 400px; top: 0; bottom: 0;"></div>
<!--map-->
<div id="map" style="position: absolute; right: 0; left: 400px; top: 0; bottom: 0;"></div>
<div id="map" style="position: absolute; right: 0; left: 0; top: 0; bottom: 0;"></div>

<!--javascript imports-->
<!--
Expand Down Expand Up @@ -97,7 +97,11 @@

===================== */

var grabpoints = function(x){var coords = [x[1], x[0]]; return coords}
var plotpoints = function(x){L.marker(x).addTo(map)}

var points = data.map(grabpoints)
points.map(plotpoints)

/* =====================

Expand Down
20 changes: 19 additions & 1 deletion lab/lab2/part1-functions-are-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,25 @@
A hint to get you started: functions are often used to label a unit of work (such as
testing whether or not a value is a string).
**/
for (var i = 0; i < theArray.length, i++) { /* Do stuff here */ }

var thinking = function(x){
if (typeof x === 'string') {
return x.length;
} else if (typeof x === 'number') {
return x;
} else {
return 0;
console.log("Not sure how to proceed with value: " + x);
}
}

var doing = function(x){
return yourSum = yourSum + x
}

var newSum = theArray.map(thinking).map(doing)

console.log(newSum)

/* =====================

Expand Down
8 changes: 6 additions & 2 deletions lab/lab2/part4-convert-csv.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@

===================== */

// feel free to comment this line out if it is too noisy in your console!
console.log(healthCentersCSV)
var facilities = healthCentersCSV
var splitter = function(x){return x.split(',')}
var splitup = facilities.split(';').map(splitter)

console.log(splitup)
console.log(splitup[0])

/* =====================

Expand Down