From 7af001bc8db0272ccc4f1522fc14e63a4a3fb58c Mon Sep 17 00:00:00 2001 From: caglenoah Date: Tue, 18 Jul 2023 11:06:27 -0600 Subject: [PATCH 1/3] initial commit 7/18) --- sorting.js | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 sorting.js diff --git a/sorting.js b/sorting.js new file mode 100644 index 0000000..0405e86 --- /dev/null +++ b/sorting.js @@ -0,0 +1,150 @@ + const strNums = ["1","4","1","5","9","2","6","5","3","5","8","9","7","9","3","2","3","8","4","6","2","6","4","3","3","8","3","2","7","9","5","0","2","8","8","4","1","9","7","1","6","9","3","9","9","3","7","5","1","0","5","8","2","0","9","7","4","9","4","4","5","9","2","3","0","7","8","1","6","4","0","6","2","8","6","2","0","8","9","9","8","6","2","8","0","3","4","8","2","5","3","4","2","1","1","7","0","6","7","9","8","2","1","4","8","0","8","6","5","1","3","2","8","2","3","0","6","6","4","7","0","9","3","8","4","4","6","0","9","5","5","0","5","8","2","2","3","1","7","2","5","3","5","9","4","0","8","1","2","8","4","8","1","1","1","7","4","5","0","2","8","4","1","0","2","7","0","1","9","3","8","5","2","1","1","0","5","5","5","9","6","4","4","6","2","2","9","4","8","9","5","4","9","3","0","3","8","1","9","6","4","4","2","8","8","1","0","9","7","5","6","6","5","9","3","3","4","4","6","1","2","8","4","7","5","6","4","8","2","3","3","7","8","6","7","8","3","1","6","5","2","7","1","2","0","1","9","0","9","1","4","5","6","4","8","5","6","6","9","2","3","4","6","0","3","4","8","6","1","0","4","5","4","3","2","6","6","4","8","2","1","3","3","9","3","6","0","7","2","6","0","2","4","9","1","4","1","2","7","3","7","2","4","5","8","7","0","0","6","6","0","6","3","1","5","5","8","8","1","7","4","8","8","1","5","2","0","9","2","0","9","6","2","8","2","9","2","5","4","0","9","1","7","1","5","3","6","4","3","6","7","8","9","2","5","9","0","3","6","0","0","1","1","3","3","0","5","3","0","5","4","8","8","2","0","4","6","6","5","2","1","3","8","4","1","4","6","9","5","1","9","4","1","5","1","1","6","0","9","4","3","3","0","5","7","2","7","0","3","6","5","7","5","9","5","9","1","9","5","3","0","9","2","1","8","6","1","1","7","3","8","1","9","3","2","6","1","1","7","9","3","1","0","5","1","1","8","5","4","8","0","7","4","4","6","2","3","7","9","9","6","2","7","4","9","5","6","7","3","5","1","8","8","5","7","5","2","7","2","4","8","9","1","2","2","7","9","3","8","1","8","3","0","1","1","9","4","9","1","2","9","8","3","3","6","7","3","3","6","2","4","4","0","6","5","6","6","4","3","0","8","6","0","2","1","3","9","4","9","4","6","3","9","5","2","2","4","7","3","7","1","9","0","7","0","2","1","7","9","8","6","0","9","4","3","7","0","2","7","7","0","5","3","9","2","1","7","1","7","6","2","9","3","1","7","6","7","5","2","3","8","4","6","7","4","8","1","8","4","6","7","6","6","9","4","0","5","1","3","2","0","0","0","5","6","8","1","2","7","1","4","5","2","6","3","5","6","0","8","2","7","7","8","5","7","7","1","3","4","2","7","5","7","7","8","9","6","0","9","1","7","3","6","3","7","1","7","8","7","2","1","4","6","8","4","4","0","9","0","1","2","2","4","9","5","3","4","3","0","1","4","6","5","4","9","5","8","5","3","7","1","0","5","0","7","9","2","2","7","9","6","8","9","2","5","8","9","2","3","5","4","2","0","1","9","9","5","6","1","1","2","1","2","9","0","2","1","9","6","0","8","6","4","0","3","4","4","1","8","1","5","9","8","1","3","6","2","9","7","7","4","7","7","1","3","0","9","9","6","0","5","1","8","7","0","7","2","1","1","3","4","9","9","9","9","9","9","8","3","7","2","9","7","8","0","4","9","9","5","1","0","5","9","7","3","1","7","3","2","8","1","6","0","9","6","3","1","8","5","9","5","0","2","4","4","5","9","4","5","5","3","4","6","9","0","8","3","0","2","6","4","2","5","2","2","3","0","8","2","5","3","3","4","4","6","8","5","0","3","5","2","6","1","9","3","1","1","8","8","1","7","1","0","1","0","0","0","3","1","3","7","8","3","8","7","5","2","8","8","6","5","8","7","5","3","3","2","0","8","3","8","1","4","2","0","6","1","7","1","7","7","6","6","9","1","4","7","3","0","3","5","9","8","2","5","3","4","9","0","4","2","8","7","5","5","4","6","8","7","3","1","1","5","9","5","6","2","8","6","3","8","8","2","3","5","3","7","8","7","5","9","3","7","5","1","9","5","7","7","8","1","8","5","7","7","8","0","5","3","2","1","7","1","2","2","6","8","0","6","6","1","3","0","0","1","9","2","7","8","7","6","6","1","1","1","9","5","9","0","9","2","1","6","4","2","0","1","9","8","9"]; + + /** - [ ] 1. Given 1000 digits of PI as strings, return an array of the digits as numbers + * - [ ] need a variable to hold the new array of nubers + * - [ ] map the original array and convert each string num into a number + * - [ ] return the new array + */ +const stringsToNumbs = (numbers) => { + const arrOfNum = strNums.map(num => parseInt(num)); + + console.log(stringToNums); +} + + + + + //2. With the same numbers, find the sum of the even values + const sumEvens; + + console.log(sumEvens); + + // 3.Find the index of the first value when added to it's index = 512 (#ATX!!) + const atxIdx; + + console.log(`index: ${atxIdx}, value: ${nums[atxIdx]}`); + + const weather = [ + { id: 5743823523151872, + weather_state_name: "Light Cloud", + weather_state_abbr: "lc", + wind_direction_compass: "NNE", + created: "2018-07-11T20:53:03.251710Z", + applicable_date: "2018-07-11", + min_temp: 14.43, + max_temp: 23.36, + the_temp: 22.785, + wind_speed: 5.682503989556987, + wind_direction: 21.6264939172659, + air_pressure: 1024.45, + humidity: 58, + visibility: 8.683041040324504, + predictability: 70 + }, + { id: 6188149969518592, + weather_state_name: "Heavy Cloud", + weather_state_abbr: "hc", + wind_direction_compass: "NE", + created: "2018-07-11T20:53:03.268190Z", + applicable_date: "2018-07-12", + min_temp: 14.81, + max_temp: 25.52, + the_temp: 24.61, + wind_speed: 3.2461141472739206, + wind_direction: 42.72552812997726, + air_pressure: 1024.605, + humidity: 54, + visibility: 10.633835898353615, + predictability: 71 + }, + { id: 5742049676492800, + weather_state_name: "Showers", + weather_state_abbr: "s", + wind_direction_compass: "E", + created: "2018-07-11T20:53:03.947390Z", + applicable_date: "2018-07-13", + min_temp: 15.5525, + max_temp: 25.3475, + the_temp: 24.175, + wind_speed: 3.6572546846814604, + wind_direction: 90.32910675612557, + air_pressure: 1025.385, + humidity: 57, + visibility: 10.181166984808717, + predictability: 73 + }, + { id: 6696130918219776, + weather_state_name: "Heavy Cloud", + weather_state_abbr: "hc", + wind_direction_compass: "SSW", + created: "2018-07-11T20:53:04.068570Z", + applicable_date: "2018-07-14", + min_temp: 15.915, + max_temp: 27.0925, + the_temp: 26.585, + wind_speed: 3.649847972759087, + wind_direction: 200.04283406736377, + air_pressure: 1024.4450000000002, + humidity: 52, + visibility: 11.14056410562316, + predictability: 71 + }, + ], + + //4. using a higher order function, create an array of the unique 'weather_state_name' values of the weather array. Your function should return the following array ['Light Cloud', 'Heavy Cloud', 'Showers'] + const weatherStates = + console.log(weatherStates) + + //5. find the id of the object in weather that has a min_temp of 15.915 + + const idealTemp = + console.log(idealTemp) + + + + + + + + + + + /**Notes:------------------------- + * methods() + * -map() + * ~array.prototype.map(): returns a new array populated with the results of calling a provided function on every element in the calling array. + * + * + */ + + + + + + /**Rubric:-------------------------- +* Each correct problem (16 pts. per) +* ES6 Syntax (10 pts.) +* Clean pull request (10 pts.) + * + */ + +/**Isntructions:------------------------- + * 1. - [ ] Given 1000 digits of PI as strings, return an array of the digits as numbers + * 3. - [ ] Find the index of the first value when added to it's index = 512 (#ATX!!) + * 2. - [ ] With the same numbers, find the sum of the even value + * 4. - [ ] using a higher order function, create an array of the unique 'weather_state_name' values of the weather array. Your function should return the following array ['Light Cloud', 'Heavy Cloud', 'Showers'] + * 5. - [ ] find the id of the object in weather that has a min_temp of 15.915 + */ + +/**SUBMIT!! YOU NEED THE PRACTICE + * How to Submit: + +- [ ] Create a new repo called: "JS-Sorting-Practice". +- [ ] Get into the practice of working with branches by creating a new branch called "sorting-branch". +- [ ] Complete a code plan. +- [ ] Create a new file called `sorting.js`. +- [ ] Copy/paste & complete the code below using the rubric below. +- [ ] Make a pull request against your master branch and submit the URL to it as your assignment. + + * + */ \ No newline at end of file From b2d9db6c062e33ed0b5fa5be4ac3e40c7853e5d5 Mon Sep 17 00:00:00 2001 From: caglenoah Date: Tue, 18 Jul 2023 11:17:07 -0600 Subject: [PATCH 2/3] update --- main.js | 4 ++++ sorting.js | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index e69de29..5570944 100644 --- a/main.js +++ b/main.js @@ -0,0 +1,4 @@ +//Rubric: +// * Each correct problem (16 pts. per) +// * ES6 Syntax (10 pts.) +// * Clean pull request (10 pts.) diff --git a/sorting.js b/sorting.js index 0405e86..abac01f 100644 --- a/sorting.js +++ b/sorting.js @@ -1,14 +1,13 @@ const strNums = ["1","4","1","5","9","2","6","5","3","5","8","9","7","9","3","2","3","8","4","6","2","6","4","3","3","8","3","2","7","9","5","0","2","8","8","4","1","9","7","1","6","9","3","9","9","3","7","5","1","0","5","8","2","0","9","7","4","9","4","4","5","9","2","3","0","7","8","1","6","4","0","6","2","8","6","2","0","8","9","9","8","6","2","8","0","3","4","8","2","5","3","4","2","1","1","7","0","6","7","9","8","2","1","4","8","0","8","6","5","1","3","2","8","2","3","0","6","6","4","7","0","9","3","8","4","4","6","0","9","5","5","0","5","8","2","2","3","1","7","2","5","3","5","9","4","0","8","1","2","8","4","8","1","1","1","7","4","5","0","2","8","4","1","0","2","7","0","1","9","3","8","5","2","1","1","0","5","5","5","9","6","4","4","6","2","2","9","4","8","9","5","4","9","3","0","3","8","1","9","6","4","4","2","8","8","1","0","9","7","5","6","6","5","9","3","3","4","4","6","1","2","8","4","7","5","6","4","8","2","3","3","7","8","6","7","8","3","1","6","5","2","7","1","2","0","1","9","0","9","1","4","5","6","4","8","5","6","6","9","2","3","4","6","0","3","4","8","6","1","0","4","5","4","3","2","6","6","4","8","2","1","3","3","9","3","6","0","7","2","6","0","2","4","9","1","4","1","2","7","3","7","2","4","5","8","7","0","0","6","6","0","6","3","1","5","5","8","8","1","7","4","8","8","1","5","2","0","9","2","0","9","6","2","8","2","9","2","5","4","0","9","1","7","1","5","3","6","4","3","6","7","8","9","2","5","9","0","3","6","0","0","1","1","3","3","0","5","3","0","5","4","8","8","2","0","4","6","6","5","2","1","3","8","4","1","4","6","9","5","1","9","4","1","5","1","1","6","0","9","4","3","3","0","5","7","2","7","0","3","6","5","7","5","9","5","9","1","9","5","3","0","9","2","1","8","6","1","1","7","3","8","1","9","3","2","6","1","1","7","9","3","1","0","5","1","1","8","5","4","8","0","7","4","4","6","2","3","7","9","9","6","2","7","4","9","5","6","7","3","5","1","8","8","5","7","5","2","7","2","4","8","9","1","2","2","7","9","3","8","1","8","3","0","1","1","9","4","9","1","2","9","8","3","3","6","7","3","3","6","2","4","4","0","6","5","6","6","4","3","0","8","6","0","2","1","3","9","4","9","4","6","3","9","5","2","2","4","7","3","7","1","9","0","7","0","2","1","7","9","8","6","0","9","4","3","7","0","2","7","7","0","5","3","9","2","1","7","1","7","6","2","9","3","1","7","6","7","5","2","3","8","4","6","7","4","8","1","8","4","6","7","6","6","9","4","0","5","1","3","2","0","0","0","5","6","8","1","2","7","1","4","5","2","6","3","5","6","0","8","2","7","7","8","5","7","7","1","3","4","2","7","5","7","7","8","9","6","0","9","1","7","3","6","3","7","1","7","8","7","2","1","4","6","8","4","4","0","9","0","1","2","2","4","9","5","3","4","3","0","1","4","6","5","4","9","5","8","5","3","7","1","0","5","0","7","9","2","2","7","9","6","8","9","2","5","8","9","2","3","5","4","2","0","1","9","9","5","6","1","1","2","1","2","9","0","2","1","9","6","0","8","6","4","0","3","4","4","1","8","1","5","9","8","1","3","6","2","9","7","7","4","7","7","1","3","0","9","9","6","0","5","1","8","7","0","7","2","1","1","3","4","9","9","9","9","9","9","8","3","7","2","9","7","8","0","4","9","9","5","1","0","5","9","7","3","1","7","3","2","8","1","6","0","9","6","3","1","8","5","9","5","0","2","4","4","5","9","4","5","5","3","4","6","9","0","8","3","0","2","6","4","2","5","2","2","3","0","8","2","5","3","3","4","4","6","8","5","0","3","5","2","6","1","9","3","1","1","8","8","1","7","1","0","1","0","0","0","3","1","3","7","8","3","8","7","5","2","8","8","6","5","8","7","5","3","3","2","0","8","3","8","1","4","2","0","6","1","7","1","7","7","6","6","9","1","4","7","3","0","3","5","9","8","2","5","3","4","9","0","4","2","8","7","5","5","4","6","8","7","3","1","1","5","9","5","6","2","8","6","3","8","8","2","3","5","3","7","8","7","5","9","3","7","5","1","9","5","7","7","8","1","8","5","7","7","8","0","5","3","2","1","7","1","2","2","6","8","0","6","6","1","3","0","0","1","9","2","7","8","7","6","6","1","1","1","9","5","9","0","9","2","1","6","4","2","0","1","9","8","9"]; /** - [ ] 1. Given 1000 digits of PI as strings, return an array of the digits as numbers - * - [ ] need a variable to hold the new array of nubers - * - [ ] map the original array and convert each string num into a number - * - [ ] return the new array + * - [ /] need a variable to hold the new array of nubers + * - [ /] map the original array and convert each string num into a number + * - [ /] return the new array */ -const stringsToNumbs = (numbers) => { +const stringsToNumbers = (numbers) => { const arrOfNum = strNums.map(num => parseInt(num)); - - console.log(stringToNums); + console.log(stringToNumbers); } @@ -139,8 +138,9 @@ const stringsToNumbs = (numbers) => { /**SUBMIT!! YOU NEED THE PRACTICE * How to Submit: -- [ ] Create a new repo called: "JS-Sorting-Practice". +- [x] Create a new repo called: "JS-Sorting-Practice". - [ ] Get into the practice of working with branches by creating a new branch called "sorting-branch". + - check configuration git remote -v - [ ] Complete a code plan. - [ ] Create a new file called `sorting.js`. - [ ] Copy/paste & complete the code below using the rubric below. From e471e625c6db0d2d1491dfaa35c94fd84e38c4f0 Mon Sep 17 00:00:00 2001 From: caglenoah Date: Wed, 2 Aug 2023 02:49:53 -0600 Subject: [PATCH 3/3] still need to do the weather --- package-lock.json | 6 ++++ sorting.js | 28 ++++++++++++++---- sortingNums.js | 69 +++++++++++++++++++++++++++++++++++++++++++ sortingWeatherInfo.js | 0 4 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 package-lock.json create mode 100644 sortingNums.js create mode 100644 sortingWeatherInfo.js diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..32eb931 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "JS211-SortingPractice", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/sorting.js b/sorting.js index abac01f..88dfcc1 100644 --- a/sorting.js +++ b/sorting.js @@ -7,21 +7,36 @@ */ const stringsToNumbers = (numbers) => { const arrOfNum = strNums.map(num => parseInt(num)); - console.log(stringToNumbers); + console.log(stringsToNumbers); } //2. With the same numbers, find the sum of the even values - const sumEvens; +//use reduce()!!!!! +// create a variable to store the sum---- + // should return as one value (sum)---- +// need to iterate throught the array and identify the index of each even number---- + //- need to define even number use find()!!! + //-loop should stop after first iteration through the array---- + //- if number is even add to total + //- if number is odd move on +// as it gathers the even numbers it needs to add them together. + +const evens = arrOfNum.find() +const sumOfEvens = + + + - console.log(sumEvens); + + // console.log(sumEvens); // 3.Find the index of the first value when added to it's index = 512 (#ATX!!) - const atxIdx; + // const atxIdx; - console.log(`index: ${atxIdx}, value: ${nums[atxIdx]}`); + // console.log(`index: ${atxIdx}, value: ${nums[atxIdx]}`); const weather = [ { id: 5743823523151872, @@ -88,7 +103,7 @@ const stringsToNumbers = (numbers) => { visibility: 11.14056410562316, predictability: 71 }, - ], + ] //4. using a higher order function, create an array of the unique 'weather_state_name' values of the weather array. Your function should return the following array ['Light Cloud', 'Heavy Cloud', 'Showers'] const weatherStates = @@ -129,6 +144,7 @@ const stringsToNumbers = (numbers) => { /**Isntructions:------------------------- * 1. - [ ] Given 1000 digits of PI as strings, return an array of the digits as numbers + * * 3. - [ ] Find the index of the first value when added to it's index = 512 (#ATX!!) * 2. - [ ] With the same numbers, find the sum of the even value * 4. - [ ] using a higher order function, create an array of the unique 'weather_state_name' values of the weather array. Your function should return the following array ['Light Cloud', 'Heavy Cloud', 'Showers'] diff --git a/sortingNums.js b/sortingNums.js new file mode 100644 index 0000000..2432ebb --- /dev/null +++ b/sortingNums.js @@ -0,0 +1,69 @@ +//given array that define an array of strings represented as numbers +const strNums = ["1", "4", "1", "5", "9", "2", "6", "5", "3", "5", "8", "9", "7", "9", "3", "2", "3", "8", "4", "6", "2", "6", "4", "3", "3", "8", "3", "2", "7", "9", "5", "0", "2", "8", "8", "4", "1", "9", "7", "1", "6", "9", "3", "9", "9", "3", "7", "5", "1", "0", "5", "8", "2", "0", "9", "7", "4", "9", "4", "4", "5", "9", "2", "3", "0", "7", "8", "1", "6", "4", "0", "6", "2", "8", "6", "2", "0", "8", "9", "9", "8", "6", "2", "8", "0", "3", "4", "8", "2", "5", "3", "4", "2", "1", "1", "7", "0", "6", "7", "9", "8", "2", "1", "4", "8", "0", "8", "6", "5", "1", "3", "2", "8", "2", "3", "0", "6", "6", "4", "7", "0", "9", "3", "8", "4", "4", "6", "0", "9", "5", "5", "0", "5", "8", "2", "2", "3", "1", "7", "2", "5", "3", "5", "9", "4", "0", "8", "1", "2", "8", "4", "8", "1", "1", "1", "7", "4", "5", "0", "2", "8", "4", "1", "0", "2", "7", "0", "1", "9", "3", "8", "5", "2", "1", "1", "0", "5", "5", "5", "9", "6", "4", "4", "6", "2", "2", "9", "4", "8", "9", "5", "4", "9", "3", "0", "3", "8", "1", "9", "6", "4", "4", "2", "8", "8", "1", "0", "9", "7", "5", "6", "6", "5", "9", "3", "3", "4", "4", "6", "1", "2", "8", "4", "7", "5", "6", "4", "8", "2", "3", "3", "7", "8", "6", "7", "8", "3", "1", "6", "5", "2", "7", "1", "2", "0", "1", "9", "0", "9", "1", "4", "5", "6", "4", "8", "5", "6", "6", "9", "2", "3", "4", "6", "0", "3", "4", "8", "6", "1", "0", "4", "5", "4", "3", "2", "6", "6", "4", "8", "2", "1", "3", "3", "9", "3", "6", "0", "7", "2", "6", "0", "2", "4", "9", "1", "4", "1", "2", "7", "3", "7", "2", "4", "5", "8", "7", "0", "0", "6", "6", "0", "6", "3", "1", "5", "5", "8", "8", "1", "7", "4", "8", "8", "1", "5", "2", "0", "9", "2", "0", "9", "6", "2", "8", "2", "9", "2", "5", "4", "0", "9", "1", "7", "1", "5", "3", "6", "4", "3", "6", "7", "8", "9", "2", "5", "9", "0", "3", "6", "0", "0", "1", "1", "3", "3", "0", "5", "3", "0", "5", "4", "8", "8", "2", "0", "4", "6", "6", "5", "2", "1", "3", "8", "4", "1", "4", "6", "9", "5", "1", "9", "4", "1", "5", "1", "1", "6", "0", "9", "4", "3", "3", "0", "5", "7", "2", "7", "0", "3", "6", "5", "7", "5", "9", "5", "9", "1", "9", "5", "3", "0", "9", "2", "1", "8", "6", "1", "1", "7", "3", "8", "1", "9", "3", "2", "6", "1", "1", "7", "9", "3", "1", "0", "5", "1", "1", "8", "5", "4", "8", "0", "7", "4", "4", "6", "2", "3", "7", "9", "9", "6", "2", "7", "4", "9", "5", "6", "7", "3", "5", "1", "8", "8", "5", "7", "5", "2", "7", "2", "4", "8", "9", "1", "2", "2", "7", "9", "3", "8", "1", "8", "3", "0", "1", "1", "9", "4", "9", "1", "2", "9", "8", "3", "3", "6", "7", "3", "3", "6", "2", "4", "4", "0", "6", "5", "6", "6", "4", "3", "0", "8", "6", "0", "2", "1", "3", "9", "4", "9", "4", "6", "3", "9", "5", "2", "2", "4", "7", "3", "7", "1", "9", "0", "7", "0", "2", "1", "7", "9", "8", "6", "0", "9", "4", "3", "7", "0", "2", "7", "7", "0", "5", "3", "9", "2", "1", "7", "1", "7", "6", "2", "9", "3", "1", "7", "6", "7", "5", "2", "3", "8", "4", "6", "7", "4", "8", "1", "8", "4", "6", "7", "6", "6", "9", "4", "0", "5", "1", "3", "2", "0", "0", "0", "5", "6", "8", "1", "2", "7", "1", "4", "5", "2", "6", "3", "5", "6", "0", "8", "2", "7", "7", "8", "5", "7", "7", "1", "3", "4", "2", "7", "5", "7", "7", "8", "9", "6", "0", "9", "1", "7", "3", "6", "3", "7", "1", "7", "8", "7", "2", "1", "4", "6", "8", "4", "4", "0", "9", "0", "1", "2", "2", "4", "9", "5", "3", "4", "3", "0", "1", "4", "6", "5", "4", "9", "5", "8", "5", "3", "7", "1", "0", "5", "0", "7", "9", "2", "2", "7", "9", "6", "8", "9", "2", "5", "8", "9", "2", "3", "5", "4", "2", "0", "1", "9", "9", "5", "6", "1", "1", "2", "1", "2", "9", "0", "2", "1", "9", "6", "0", "8", "6", "4", "0", "3", "4", "4", "1", "8", "1", "5", "9", "8", "1", "3", "6", "2", "9", "7", "7", "4", "7", "7", "1", "3", "0", "9", "9", "6", "0", "5", "1", "8", "7", "0", "7", "2", "1", "1", "3", "4", "9", "9", "9", "9", "9", "9", "8", "3", "7", "2", "9", "7", "8", "0", "4", "9", "9", "5", "1", "0", "5", "9", "7", "3", "1", "7", "3", "2", "8", "1", "6", "0", "9", "6", "3", "1", "8", "5", "9", "5", "0", "2", "4", "4", "5", "9", "4", "5", "5", "3", "4", "6", "9", "0", "8", "3", "0", "2", "6", "4", "2", "5", "2", "2", "3", "0", "8", "2", "5", "3", "3", "4", "4", "6", "8", "5", "0", "3", "5", "2", "6", "1", "9", "3", "1", "1", "8", "8", "1", "7", "1", "0", "1", "0", "0", "0", "3", "1", "3", "7", "8", "3", "8", "7", "5", "2", "8", "8", "6", "5", "8", "7", "5", "3", "3", "2", "0", "8", "3", "8", "1", "4", "2", "0", "6", "1", "7", "1", "7", "7", "6", "6", "9", "1", "4", "7", "3", "0", "3", "5", "9", "8", "2", "5", "3", "4", "9", "0", "4", "2", "8", "7", "5", "5", "4", "6", "8", "7", "3", "1", "1", "5", "9", "5", "6", "2", "8", "6", "3", "8", "8", "2", "3", "5", "3", "7", "8", "7", "5", "9", "3", "7", "5", "1", "9", "5", "7", "7", "8", "1", "8", "5", "7", "7", "8", "0", "5", "3", "2", "1", "7", "1", "2", "2", "6", "8", "0", "6", "6", "1", "3", "0", "0", "1", "9", "2", "7", "8", "7", "6", "6", "1", "1", "1", "9", "5", "9", "0", "9", "2", "1", "6", "4", "2", "0", "1", "9", "8", "9"]; + + + // - [ ] 1. Given 1000 digits of PI as strings, return an array of the digits as numbers +// * - [ /] need a variable to hold the new array of nubers +// * - [ /] map the original array and convert each string num into a number +// * - [ /] return the new array + +//USE MAP() + +// function that converts array of strings to an array of integers +const stringsToNumbers = (numbers) => { +//use .map() to convert each string to an intiger + const arrOfNum = numbers.map(num => parseInt(num)); + //returns the resulting array of integers + return arrOfNum; +}; + + + +//2. With the same numbers, find the sum of the even values +//use reduce()!!!!! +// create a variable to store the sum + // should return as one value (sum +// need to iterate throught the array and identify the index of each even number---- + //-loop should stop after first iteration through the array + //- if number is even add to total + //- if number is odd move on +// as it gathers the even numbers it needs to add them together. + + +// USE FILTER() +// USE REDUCE() + +//converts the original array to numbers by calling stringToNumbers() function +const arrOfNum = stringsToNumbers(strNums); +//use filter() to initialize new array with only even values extracted from the arrOfNum +const evenNumbers = arrOfNum.filter(num => num % 2 === 0); +//use reduce() to initializes variable and stores the sum of all the even numbers in arrOfNum as a single value +const sumOfEvenNumbers = evenNumbers.reduce((acc, num) => acc + num, 0); + +console.log(sumOfEvenNumbers); + +// 3.Find the index of the first value when added to it's index = 512 (#ATX!!) +// Loop through the nums array. +// For each element in the array, add its value to its own index. +// Check if the sum is equal to 512. +// If you find an element that satisfies the condition, store its index in the variable atxIdx. + + +//USE FINDINDEX() + + +//function that finds the index where the sum of the element value and index equals 512. If it is unable to do so it will let the user know there is no element/index where this is the case +const findIndexOfSumEqualTo512 = (arr) => { + //use findIndex() to find the index that satisfies the condition + const atxIdx = arr.findIndex((num, index) => num + index === 512); + return atxIdx; + }; + +//Finding the index in the arrOfNum array where the sum of the element value and index equals 512 + const atxIdx = findIndexOfSumEqualTo512(arrOfNum); + //checks if disired sum was found and prints the result or returns message letting user know that index does not exist based on given condition + if (atxIdx !== -1) { + console.log(`index: ${atxIdx}, value: ${arrOfNum[atxIdx]}`); + } else { + console.log("No value found where value + index equals 512."); + } \ No newline at end of file diff --git a/sortingWeatherInfo.js b/sortingWeatherInfo.js new file mode 100644 index 0000000..e69de29