From f5b59ac24e07208c61adec921c9c9da3fc5bf58b Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 27 Jan 2020 20:44:11 -0500 Subject: [PATCH 1/4] Labs --- lab/lab1/part1-types-variables-math.html | 10 +++++----- lab/lab1/part2-fizzbuzz.html | 22 +++++++++------------- lab/lab1/part3-array-access.html | 11 ++++++++--- lab/lab2/part1-functions-are-values.html | 20 +++++++++++++++++++- lab/lab2/part4-convert-csv.html | 8 ++++++-- 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/lab/lab1/part1-types-variables-math.html b/lab/lab1/part1-types-variables-math.html index 0040462..17ec8d6 100755 --- a/lab/lab1/part1-types-variables-math.html +++ b/lab/lab1/part1-types-variables-math.html @@ -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); /* ===================== diff --git a/lab/lab1/part2-fizzbuzz.html b/lab/lab1/part2-fizzbuzz.html index 39e49a9..711b039 100644 --- a/lab/lab1/part2-fizzbuzz.html +++ b/lab/lab1/part2-fizzbuzz.html @@ -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') + } + } diff --git a/lab/lab1/part3-array-access.html b/lab/lab1/part3-array-access.html index cd460eb..7900a80 100644 --- a/lab/lab1/part3-array-access.html +++ b/lab/lab1/part3-array-access.html @@ -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); + } /* ===================== diff --git a/lab/lab2/part1-functions-are-values.html b/lab/lab2/part1-functions-are-values.html index 22889d4..661bb7c 100644 --- a/lab/lab2/part1-functions-are-values.html +++ b/lab/lab2/part1-functions-are-values.html @@ -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) /* ===================== diff --git a/lab/lab2/part4-convert-csv.html b/lab/lab2/part4-convert-csv.html index 0d839b8..3264aec 100644 --- a/lab/lab2/part4-convert-csv.html +++ b/lab/lab2/part4-convert-csv.html @@ -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]) /* ===================== From 82ec29fb008aa699189958645ab6b4724ae6140a Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 27 Jan 2020 20:58:50 -0500 Subject: [PATCH 2/4] Update lab --- lab/lab1/part4-data-transformation.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lab/lab1/part4-data-transformation.html b/lab/lab1/part4-data-transformation.html index 0e6ea09..933d2ce 100644 --- a/lab/lab1/part4-data-transformation.html +++ b/lab/lab1/part4-data-transformation.html @@ -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) /* ===================== From 6dcaa6df4d27c43a733dc09f070efad45c2adab2 Mon Sep 17 00:00:00 2001 From: andrew Date: Mon, 27 Jan 2020 21:03:29 -0500 Subject: [PATCH 3/4] Expand map --- lab/lab1/part4-data-transformation.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab/lab1/part4-data-transformation.html b/lab/lab1/part4-data-transformation.html index 933d2ce..f6c1acf 100644 --- a/lab/lab1/part4-data-transformation.html +++ b/lab/lab1/part4-data-transformation.html @@ -9,7 +9,7 @@
-
+
-
-
-
+
@@ -31,6 +28,7 @@ }).addTo(map);