diff --git a/assignment/index.html b/assignment/index.html index 33922b5..8ac57e6 100644 --- a/assignment/index.html +++ b/assignment/index.html @@ -63,9 +63,34 @@ ===================== */ var jsonToCsv = function(json) { console.log(json); }; + var addMarkers = function(map) {}; - var addMarkers = function(map) {}; +//Part 1 +//Log a series of arrays to the console that represents the health_centers dataset in array form. +//Code guidance: https://openclassrooms.com/en/courses/3523231-learn-to-code-with-javascript/3703666-store-data-in-arrays + +//My initial attempt did not create an array of arrays...tried a different approach +//Code guidance: CodeCademy Introduction To JavaScript 6-8 +//Code guidance: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values +//Code guidance: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map +//Code guidance: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/keys +//Code guidance: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat + + var returnValues = function (obj) {return Object.values(obj)};//Establishes a function to return object values + var valuesHC = healthCenters.map(returnValues);//Creates a new array from healthCenters data for each center using created function + var keysHC = [Object.keys(healthCenters[0])];//Creates an array of healthCenters keys + var arrayOfArrays = keysHC.concat(valuesHC);//Merges array of keys with array of health care data + console.log(arrayOfArrays);//Console logs the array of arrays + +//Part 2 +//Put a marker on the map for each health center in the specified lat/lng coordinates with a popup (a simple text dialog) that +//shows that location's name when its marker is clicked. +//Code guidance: https://leafletjs.com/examples/layers-control/ & https://leafletjs.com/examples/custom-icons/ + +var addMarker = function(x) { return L.marker([x.LAT, x.LNG]).bindPopup(x.NAME) }//function that returns a marker (lat,lng) and popup (name) for a variable +for (var i=0; i 30); - var b; + var b = "abc"; 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 = 28; var resultTask5 = (e%5 == 3); /* ===================== diff --git a/lab/lab1/part2.js b/lab/lab1/part2.js index b1bccb9..2cc0f4a 100644 --- a/lab/lab1/part2.js +++ b/lab/lab1/part2.js @@ -7,7 +7,7 @@ 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); @@ -17,7 +17,7 @@ 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); @@ -28,7 +28,7 @@ if so, it returns even or odd depending on the number, otherwise it returns "err ===================== */ -var oddOrEven = function() {}; +var oddOrEven = function isInt8(n) {return +n === n && !(n % 1)}; console.log('oddOrEven success:', oddOrEven(100) === 'even' && oddOrEven(201) === 'odd'); diff --git a/lab/lab2/part1-functions-are-values.html b/lab/lab2/part1-functions-are-values.html index d0aec5e..1ac94f5 100644 --- a/lab/lab2/part1-functions-are-values.html +++ b/lab/lab2/part1-functions-are-values.html @@ -68,7 +68,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*/ } /* =====================