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 Yichao Jia #17

Open
wants to merge 2 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/marker-icon1.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/marker-icon2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 32 additions & 7 deletions assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,45 @@

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

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


var addMarkers = function(map) {};
var csvHC = [];

/* =====================
var jsonToCsv = (obj) => {
csvHC.push(Object.keys(obj[0]));
for (i = 0; i < obj.length; i++) {
csvHC.push(Object.values(obj[i]))
}
};

End code
jsonToCsv(healthCenters);

===================== */
console.log(csvHC);

var myIcon1 = L.icon({iconUrl:'images/marker-icon1.png',
shadowUrl:'images/marker-shadow.png'});

var myIcon2 = L.icon({iconUrl:'images/marker-icon2.png',
shadowUrl:'images/marker-shadow.png'});


var addMarkers = (obj) => {
for (var i = 1 ; i < obj.length; i++) {
if (obj[i][5]>=19140 && obj[i][5]<=19149) {
if (obj[i][8]!="N/A") {
L.marker([obj[i][1],obj[i][0]],{icon: myIcon1}).addTo(map)
.bindPopup(obj[i][3])
} else {
L.marker([obj[i][1],obj[i][0]],{icon: myIcon2}).addTo(map)
.bindPopup(obj[i][3])
}
}
}
}


addMarkers(csvHC);

jsonToCsv(healthCenters);
addMarkers(map);
</script>
<!--Your code ends here-->
</body>
Expand Down
23 changes: 19 additions & 4 deletions lab/lab1/part2.js → lab/lab1/js/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 num + 2;
};

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

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

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

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

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

Expand All @@ -49,7 +58,13 @@ 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 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 = 'hah';
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 = 8;
var resultTask5 = (e%5 == 3);

/* =====================
Expand Down
3 changes: 2 additions & 1 deletion lab/lab1/part2-function-review.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<title>Page Title</title>
</head>
<body>
<h1> Hello World </h1>
<!-- Javascript Imports -->
<script src="part2.js"></script>
<script src="js/part2.js"></script>
</body>
</html>
7 changes: 5 additions & 2 deletions lab/lab2/part1-functions-are-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
exampleSum = exampleSum + arrayValue.length
} else if (typeof arrayValue === 'number') { // Number case
exampleSum = exampleSum + arrayValue
} else { // Otherwise
} else if (arraycondition) {
exampleSum = exampleSum + arra
}
else { // Otherwise
console.log("Not sure how to proceed with value:", arrayValue)
}
}
Expand Down Expand Up @@ -68,7 +71,7 @@

/* Define your function here */

for (var i = 0; i < theArray.length, i++) { /* Inside the loop*/ }
for (var i = 0; i < theArray.length; i++) { /* Inside the loop*/ }

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

Expand Down