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

HW2- Yue Guo #9

Open
wants to merge 3 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.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 94 additions & 45 deletions assignment/index.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<!--stylesheet imports-->
<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>

<!--javascript imports-->
<script src="leaflet.js"></script>
<script src="health_centers.js"></script>

<!--Your code starts here-->
<script>
var map = L.map('map', {
center: [39.9522, -75.1639],
zoom: 14
});
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>',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20,
ext: 'png'
}).addTo(map);
</script>
<script>
/* =====================

<head>
<!--stylesheet imports-->
<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>

<!--javascript imports-->
<script src="leaflet.js"></script>
<script src="health_centers.js"></script>

<!--Your code starts here-->
<script>
var map = L.map('map', {
center: [39.9522, -75.1639],
zoom: 14
});
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>',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20,
ext: 'png'
}).addTo(map);
</script>
<script>
/* =====================

# Week 2 - Assignment

Expand All @@ -56,27 +58,74 @@
===================== */


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

Start code
Start code

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

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

// PART 1

var addMarkers = function(map) {};
const key = Object.keys(healthCenters[0]);
const list = [
[key],
]; //Master list to be used in console.log

/* =====================
for (let i = 0; i < healthCenters.length; i++) {
let storage = []; //Used to store information about each health center waiting to be pushed to the master list
for (let j = 0; j < key.length; j++) {
storage.push(healthCenters[i][key[j]]); //This stores each piece information of each health center
}
list.push(storage); //Pushes stored information to the master list
}
console.log(list);

End code
// PART 2

// First define two types of markers
var iconWithDental = L.icon ({
iconUrl: 'images/dental.png', // Set marker image to the tooth image.
})
var iconWODental = L.icon ({
iconUrl: 'images/marker-icon.png', // Use the default image
})

// Add marker and popup for each health center, checking for dental phone
for (let k = 0; k < healthCenters.length; k++) {
if (healthCenters[k].DENTAL_PHONE === 'N/A') { // No dental
var marker = L.marker([healthCenters[k].LAT, healthCenters[k].LNG], {
icon: iconWODental
}).addTo(map);
popupContent = healthCenters[k].NAME;
marker.bindPopup(popupContent).openPopup();
} else { // With dental
var marker = L.marker([healthCenters[k].LAT, healthCenters[k].LNG], {
icon: iconWithDental
}).addTo(map);
popupContent = healthCenters[k].NAME;
marker.bindPopup(popupContent).openPopup();
}
}



var addMarkers = function(map) {};

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

End code

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

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

jsonToCsv(healthCenters);
addMarkers(map);
</script>
<!--Your code ends here-->
</body>

jsonToCsv(healthCenters);
addMarkers(map);
</script>
<!--Your code ends here-->
</body>
</html>
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=40;
var resultTask1 = (a > 30);

var b;
var b="THIS SUX";
var resultTask2 = (typeof b == 'string');

var c;
var c=Math.sqrt(25);
var resultTask3 = (c ** 2 == 25)
var d;

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

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

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

var plusOne = function() {};
var plusOne = function(i) {
i++;
return i;
};

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

Expand All @@ -17,7 +20,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(i) {
return plusOne(plusOne(i));
};

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

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

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

var oddOrEven = function() {};
var oddOrEven = function(i) {
if (Number.isInteger(i)) {
if (i % 2 == 0) {
return 'even';
} else {
return 'odd';
}
} else {
return 'error'
}
};

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

Expand All @@ -40,7 +55,10 @@ 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(i) {
let x = (new Date()).getFullYear() - i;
return x;
};

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

Expand All @@ -49,7 +67,9 @@ 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(i) {
return (i > 9000);
};

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

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


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

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

Expand All @@ -73,6 +99,6 @@ 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) {let y=m*x+b; return y;};

console.log('y success:', y(12, 1, 12) === 24);