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

HW02 - Yixuan Hu (Emily) #12

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
Binary file added assignment/images/Dental-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assignment/images/hospital_location-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 46 additions & 4 deletions assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script>
var map = L.map('map', {
center: [39.9522, -75.1639],
zoom: 14
zoom: 11
});
var Stamen_TonerLite = L.tileLayer('http://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.{ext}', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> &mdash; Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
Expand Down Expand Up @@ -62,10 +62,52 @@

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

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

var output = [];
output.push(Object.keys(json[0]));

var addMarkers = function(map) {};
for(var i in json) { // go through all objects in json
output.push(Object.values(json[i]));
}

console.log(output);

};

//to get the lat/lon: array.lat

//a different marker
var dentalIcon = L.icon({
iconUrl: 'images/Dental-icon.png',
iconSize: [20, 20]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cute.
but.
so tiny!

image

});
var healthcareIcon = L.icon({
iconUrl: 'images/hospital_location-512.png',
iconSize: [20, 20]
})

var addMarkers = function(map, json) {

//1st: show up healthcenters in a specific area
// Logic: go through all the objects, if ZIP is within 19140 and 19149,
// then add marker
for(var i in json) { // go through the objects array just made, from the 2nd row
if(json[i].ZIP >= 19140 && json[i].ZIP <= 19149) {
if(json[i].DENTAL_PHONE != "N/A") { //2nd: dental institutes in different marker
L.marker([json[i].LAT, json[i].LNG], {icon: dentalIcon}).addTo(map).bindPopup("Dental Service: " + json[i].NAME);
}
else {
L.marker([json[i].LAT, json[i].LNG], {icon: healthcareIcon}).addTo(map).bindPopup(json[i].NAME);
}

}

}



};

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

Expand All @@ -75,7 +117,7 @@


jsonToCsv(healthCenters);
addMarkers(map);
addMarkers(map, healthCenters);
</script>
<!--Your code ends here-->
</body>
Expand Down
12 changes: 6 additions & 6 deletions lab/lab1/part1-types-variables-math.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@

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

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

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

var c;
var c = 5;
var resultTask3 = (c ** 2 == 25)
var d;

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

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

/* =====================
Expand Down
43 changes: 36 additions & 7 deletions lab/lab1/part2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Instructions: "Write a function that adds one to the number provided"
Example: "plusOne(2) should return 3"
===================== */

var plusOne = function() {};
var plusOne = function(num) {
return num + 1;
};

console.log('plusOne success:', plusOne(99) === 100);

Expand All @@ -17,7 +19,9 @@ Example: "plusTwo(2) should return 3"
NOTE: Try using the `plusOne` function in the body of your `plusTwo` function
===================== */

var plusTwo = function() {};
var plusTwo = function(num) {
return plusOne(plusOne(num));
};

console.log('plusTwo success:', plusTwo(99) === 101);

Expand All @@ -28,7 +32,14 @@ if so, it returns even or odd depending on the number, otherwise it returns "err

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

var oddOrEven = function() {};
var oddOrEven = function(num) {
if(num % 2 == 0) {
return 'even';
}
else {
return 'odd';
}
};

console.log('oddOrEven success:', oddOrEven(100) === 'even' && oddOrEven(201) === 'odd');

Expand All @@ -40,7 +51,9 @@ Instructions: "Write a function, age, that takes a birth year and returns an age
Example: "age(2000) should return 17"
===================== */

var age = function() {};
var age = function(n) {
return 2019 - n;
};

console.log('age success:', age(1971) === 48);

Expand All @@ -49,7 +62,14 @@ Instructions: "Write a function that returns true for numbers over 9000 and fals
Example: "over9000(22) should return false"
===================== */

var over9000 = function() {};
var over9000 = function(num) {
if(num > 9000) {
return true;
}
else {
return false;
}
};

console.log('over9000 success:', over9000(9001) === true && over9000(12) === false);

Expand All @@ -61,7 +81,14 @@ and if it is not, it prints to the console, "TRY WITH STRINGS"
===================== */


var trump = function() {};
var trump = function(v) {
if(typeof v == 'string') {
return v.toUpperCase();
}
else {
return "TRY WITH STRINGS";
}
};

console.log('trump success:', trump(12) === "TRY WITH STRINGS" && trump('hi') === 'HI');

Expand All @@ -73,6 +100,8 @@ Example: "y(0, 0, 0) should return 0; y(1, 1, 1) should return 2"
===================== */


var y = function(m,x,b) {};
var y = function(m,x,b) {
return m + b;
};

console.log('y success:', y(12, 1, 12) === 24);
4 changes: 4 additions & 0 deletions lab/lab2/part1-functions-are-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
}
}

var addLength = function(arrayValue) {

}

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

Start your code below
Expand Down