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-HyoSungKim #20

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
20 changes: 18 additions & 2 deletions assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<!--Your code starts here-->
<script>
var map = L.map('map', {
center: [39.9522, -75.1639],
zoom: 14
center: [39.952408, -75.163591], //orig coordinates 39.9522,-75.1639; city hall center 39.952408, -75.163591
zoom: 12
});
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 All @@ -29,6 +29,7 @@
maxZoom: 20,
ext: 'png'
}).addTo(map);

</script>
<script>
/* =====================
Expand Down Expand Up @@ -64,9 +65,24 @@

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

//Log series of arrays
var getValues = (x) => {return Object.values(x)}
var allHealthCenters = healthCenters.map(getValues)
var getKeys = [Object.keys(healthCenters[0])]
console.log(getKeys.concat(allHealthCenters))

var addMarkers = function(map) {};

// Function to create markers and add them to the map
// Only health centers with ZIP codes between 1940 and 1949
for (i=0; i<healthCenters.length; i=i+1){
if (healthCenters[i].ZIP>=19140 & healthCenters[i].ZIP<=19149) {
marker = L.marker([healthCenters[i].LAT,healthCenters[i].LNG]);
marker.bindPopup(healthCenters[i].Name);
Copy link
Member

Choose a reason for hiding this comment

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

image

Looks like the popup name isn't working properly

marker.addTo(map);
}
}

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

End code
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 = 35;
var resultTask1 = (a > 30);

var b;
var b = 'hello world';
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
1 change: 1 addition & 0 deletions lab/lab1/part2-function-review.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>Page Title</title>
</head>
<body>
<h1> Hello World </h1>
<!-- Javascript Imports -->
<script src="part2.js"></script>
</body>
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,9 @@ Instructions: "Write a function that adds one to the number provided"
Example: "plusOne(2) should return 3"
===================== */

var plusOne = function() {};
var plusOne = function (a) {
return a + 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(b) {
return b+2;
};

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

Expand All @@ -28,7 +32,13 @@ 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 if (num%2 !== 0) {
return 'odd';
}
};

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

Expand All @@ -40,7 +50,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(birthYear) {
return 2019 - birthYear;
};

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

Expand All @@ -49,7 +61,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(val) {
if (val > 9000){
return true;
} else {
return false;
}
};

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

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


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

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

Expand All @@ -73,6 +97,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*x + b;
};

console.log('y success:', y(12, 1, 12) === 24);
43 changes: 32 additions & 11 deletions lab/lab2/part1-functions-are-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
var exampleSum = 0; // To count of the strings

// A loop for summing the contents of theArray
for (var i = 0; i < theArray.length; i++) {
var arrayValue = theArray[i];
if (typeof arrayValue === 'string') { // String case
exampleSum = exampleSum + arrayValue.length
} else if (typeof arrayValue === 'number') { // Number case
exampleSum = exampleSum + arrayValue
} else { // Otherwise
console.log("Not sure how to proceed with value:", arrayValue)
}
}
// for (var i = 0; i < theArray.length; i++) {
// var arrayValue = theArray[i];
// if (typeof arrayValue === 'string') { // String case
// exampleSum = exampleSum + arrayValue.length
// } else if (typeof arrayValue === 'number') { // Number case
// exampleSum = exampleSum + arrayValue
// } else { // Otherwise
// console.log("Not sure how to proceed with value:", arrayValue)
// }
// }

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

Expand All @@ -68,7 +68,28 @@

/* Define your function here */

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



var countValues = function (){}
for (var i = 0; i < theArray.length; i++) { /* Inside the loop*/
var arrayValue = theArray[i];
if (typeof arrayValue === 'string') { // String case
exampleSum += arrayValue.length
} else if (typeof arrayValue === 'number') { // Number case
exampleSum += arrayValue
} else if (typeof arrayValue === 'object'){
console.log('array');
countValues([arrayValue][i]);
console.log(arrayValue);
}
}


/* // Otherwise
console.log("Not sure how to proceed with value:", arrayValue)
}*/


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

Expand Down