From 2c400c389857af0fc8e97f6afc1add25420ab705 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Sat, 4 Apr 2020 20:58:11 -0600 Subject: [PATCH 01/12] SayGoodbye Function completed --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index bdafe4c8b..d6a148352 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,8 @@ function addNumbers(num1, num2) { * the returned value should look like: 'Goodbye, Andy. Have a great day.' * */ -function sayGoodbye(/* code here */) { - /* code here */ +function sayGoodbye(name) { + return 'Goodbye, ' + name + '.' + ' Have a great day.'; } /** From e1238078ab02bc462497f281831d8a1c9ede2d18 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Sat, 4 Apr 2020 21:02:41 -0600 Subject: [PATCH 02/12] temperatureCt0F finished --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index d6a148352..ad4e03ae0 100644 --- a/index.js +++ b/index.js @@ -53,8 +53,8 @@ function sayGoodbye(name) { * Hint 1: The formula for converting celsius to fahrenheit is t*9/5 + 32 where t is the temperature in celsius. * Hint 2: There is a very easy way to round numbers in JS. Do a google search to find out how. */ -function temperatureCtoF(/* code here */) { - /* code here */ +function temperatureCtoF(degreesC) { + return Math.round(degreesC * (9/5) + 32); } /** From 4af93210a0a1c6ba55df797530288532025f32e4 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Sun, 5 Apr 2020 10:19:44 -0600 Subject: [PATCH 03/12] temperatureCtoF function completed --- index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index ad4e03ae0..6f6eb1b60 100644 --- a/index.js +++ b/index.js @@ -53,8 +53,8 @@ function sayGoodbye(name) { * Hint 1: The formula for converting celsius to fahrenheit is t*9/5 + 32 where t is the temperature in celsius. * Hint 2: There is a very easy way to round numbers in JS. Do a google search to find out how. */ -function temperatureCtoF(degreesC) { - return Math.round(degreesC * (9/5) + 32); +function temperatureCtoF(degrees) { + return Math.round(degrees * (9/5) + 32); } /** @@ -74,8 +74,12 @@ function temperatureCtoF(degreesC) { * * Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`. */ -function temperatureInF(/* code here */) { - /* code here */ +function temperatureInF(degrees, unit) { + if (unit === 'F') { + return Math.round(degrees) + unit; + } else { + return temperatureCtoF(degrees) + 'F'; + } } From a629f78f25d3577f895965b6d10cff4ed1dd5a8e Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Sun, 5 Apr 2020 11:11:23 -0600 Subject: [PATCH 04/12] getName function completed --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6f6eb1b60..ac495cebb 100644 --- a/index.js +++ b/index.js @@ -99,8 +99,9 @@ function temperatureInF(degrees, unit) { * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { - /* code here */ +function makePersonObject(id, name, email) { + Object.create(person); + return person; } /** @@ -116,8 +117,8 @@ function makePersonObject(/* code here */) { * passing { id: 1, name: 'Leia', email: 'leia@leia.com` } as the argument, * the returned value should look like `Hello, my name is Leia`. */ -function getName(/* code here */) { - /* code here */ +function getName(person) { + return 'Hello, my name is ' + person.name + '.' } From 0146008f48585857af9fd9c44d2269dda4361672 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Sun, 5 Apr 2020 11:20:45 -0600 Subject: [PATCH 05/12] appleIndex function complete --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ac495cebb..e590a6556 100644 --- a/index.js +++ b/index.js @@ -137,8 +137,9 @@ function getName(person) { * passing in [ 'orange', 'grape', 'apple', 'banana', 'mango' ] as the argument, * the returned value should be: 2. */ -function appleIndex(/* code here */) { - /* code here */ +function appleIndex(fruits) { + const apple = fruits.indexOf('apple'); + return apple; } /** From 1edc19758fd5ccbda51293e2b269f5e24b2ee529 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Sun, 5 Apr 2020 16:22:20 -0600 Subject: [PATCH 06/12] modified makePersonobject function --- index.js | 21 +++++--- package-lock.json | 133 +++++++++++++++++++++++++--------------------- 2 files changed, 86 insertions(+), 68 deletions(-) diff --git a/index.js b/index.js index e590a6556..399a85001 100644 --- a/index.js +++ b/index.js @@ -100,8 +100,11 @@ function temperatureInF(degrees, unit) { * } */ function makePersonObject(id, name, email) { - Object.create(person); - return person; + let person = new Object(); + person.id = id; + person.name = name; + person.email = email; + return person; } /** @@ -118,7 +121,7 @@ function makePersonObject(id, name, email) { * the returned value should look like `Hello, my name is Leia`. */ function getName(person) { - return 'Hello, my name is ' + person.name + '.' + return 'Hello, my name is ' + person.name + '.' ; } @@ -138,8 +141,8 @@ function getName(person) { * the returned value should be: 2. */ function appleIndex(fruits) { - const apple = fruits.indexOf('apple'); - return apple; + const applePosition = fruits.indexOf('apple'); + return applePosition; } /** @@ -157,8 +160,12 @@ function appleIndex(fruits) { * passing in [ 'orange', 'apple', 'banana', 'apples', 'apple', 'mango' ] as the argument, * the returned value should be: [ false, true, false, false, true, false ]. */ -function isItAnApple(/* code here */) { - /* code here */ +function isItAnApple(fruits) { + // var applePosition = fruits.indexOf('apple'); + // return applePosition; + // if (applePosition > -1); + // return true; + } diff --git a/package-lock.json b/package-lock.json index f3c02e373..44f6abac8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,9 +35,9 @@ } }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", "dev": true }, "acorn-jsx": { @@ -1706,14 +1706,13 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "version": "1.2.12", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.12.tgz", + "integrity": "sha512-Ggd/Ktt7E7I8pxZRbGIs7vwqAPscSESMrCSkx2FtWeqmheJgCo2R74fTsZFCifr0VTPwqRpPv17+6b8Zp7th0Q==", "dev": true, "optional": true, "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" + "node-pre-gyp": "*" }, "dependencies": { "abbrev": { @@ -1761,7 +1760,7 @@ } }, "chownr": { - "version": "1.1.1", + "version": "1.1.4", "bundled": true, "dev": true, "optional": true @@ -1791,7 +1790,7 @@ "optional": true }, "debug": { - "version": "4.1.1", + "version": "3.2.6", "bundled": true, "dev": true, "optional": true, @@ -1818,12 +1817,12 @@ "optional": true }, "fs-minipass": { - "version": "1.2.5", + "version": "1.2.7", "bundled": true, "dev": true, "optional": true, "requires": { - "minipass": "^2.2.1" + "minipass": "^2.6.0" } }, "fs.realpath": { @@ -1849,7 +1848,7 @@ } }, "glob": { - "version": "7.1.3", + "version": "7.1.6", "bundled": true, "dev": true, "optional": true, @@ -1878,7 +1877,7 @@ } }, "ignore-walk": { - "version": "3.0.1", + "version": "3.0.3", "bundled": true, "dev": true, "optional": true, @@ -1897,7 +1896,7 @@ } }, "inherits": { - "version": "2.0.3", + "version": "2.0.4", "bundled": true, "dev": true, "optional": true @@ -1933,13 +1932,13 @@ } }, "minimist": { - "version": "0.0.8", + "version": "1.2.5", "bundled": true, "dev": true, "optional": true }, "minipass": { - "version": "2.3.5", + "version": "2.9.0", "bundled": true, "dev": true, "optional": true, @@ -1949,42 +1948,42 @@ } }, "minizlib": { - "version": "1.2.1", + "version": "1.3.3", "bundled": true, "dev": true, "optional": true, "requires": { - "minipass": "^2.2.1" + "minipass": "^2.9.0" } }, "mkdirp": { - "version": "0.5.1", + "version": "0.5.3", "bundled": true, "dev": true, "optional": true, "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "ms": { - "version": "2.1.1", + "version": "2.1.2", "bundled": true, "dev": true, "optional": true }, "needle": { - "version": "2.3.0", + "version": "2.3.3", "bundled": true, "dev": true, "optional": true, "requires": { - "debug": "^4.1.0", + "debug": "^3.2.6", "iconv-lite": "^0.4.4", "sax": "^1.2.4" } }, "node-pre-gyp": { - "version": "0.12.0", + "version": "0.14.0", "bundled": true, "dev": true, "optional": true, @@ -1998,11 +1997,11 @@ "rc": "^1.2.7", "rimraf": "^2.6.1", "semver": "^5.3.0", - "tar": "^4" + "tar": "^4.4.2" } }, "nopt": { - "version": "4.0.1", + "version": "4.0.3", "bundled": true, "dev": true, "optional": true, @@ -2012,19 +2011,29 @@ } }, "npm-bundled": { - "version": "1.0.6", + "version": "1.1.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "npm-normalize-package-bin": "^1.0.1" + } + }, + "npm-normalize-package-bin": { + "version": "1.0.1", "bundled": true, "dev": true, "optional": true }, "npm-packlist": { - "version": "1.4.1", + "version": "1.4.8", "bundled": true, "dev": true, "optional": true, "requires": { "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" + "npm-bundled": "^1.0.1", + "npm-normalize-package-bin": "^1.0.1" } }, "npmlog": { @@ -2089,7 +2098,7 @@ "optional": true }, "process-nextick-args": { - "version": "2.0.0", + "version": "2.0.1", "bundled": true, "dev": true, "optional": true @@ -2104,18 +2113,10 @@ "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } } }, "readable-stream": { - "version": "2.3.6", + "version": "2.3.7", "bundled": true, "dev": true, "optional": true, @@ -2130,7 +2131,7 @@ } }, "rimraf": { - "version": "2.6.3", + "version": "2.7.1", "bundled": true, "dev": true, "optional": true, @@ -2157,7 +2158,7 @@ "optional": true }, "semver": { - "version": "5.7.0", + "version": "5.7.1", "bundled": true, "dev": true, "optional": true @@ -2210,18 +2211,18 @@ "optional": true }, "tar": { - "version": "4.4.8", + "version": "4.4.13", "bundled": true, "dev": true, "optional": true, "requires": { "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", "mkdirp": "^0.5.0", "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" + "yallist": "^3.0.3" } }, "util-deprecate": { @@ -2246,7 +2247,7 @@ "optional": true }, "yallist": { - "version": "3.0.3", + "version": "3.1.1", "bundled": true, "dev": true, "optional": true @@ -2815,9 +2816,9 @@ } }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, "lcid": { @@ -3167,11 +3168,18 @@ } }, "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" + }, + "dependencies": { + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + } } }, "mocha": { @@ -3202,6 +3210,16 @@ "yargs": "13.3.0", "yargs-parser": "13.1.1", "yargs-unparser": "1.6.0" + }, + "dependencies": { + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + } } }, "mocha-junit-reporter": { @@ -3257,13 +3275,6 @@ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, - "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "dev": true, - "optional": true - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", From d4884b83fc5c2e2ef90576a7e12d2dabe1afda2d Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Tue, 7 Apr 2020 17:45:29 -0600 Subject: [PATCH 07/12] isItAnApple function finished --- index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 399a85001..998ca6f4e 100644 --- a/index.js +++ b/index.js @@ -160,14 +160,19 @@ function appleIndex(fruits) { * passing in [ 'orange', 'apple', 'banana', 'apples', 'apple', 'mango' ] as the argument, * the returned value should be: [ false, true, false, false, true, false ]. */ -function isItAnApple(fruits) { - // var applePosition = fruits.indexOf('apple'); - // return applePosition; - // if (applePosition > -1); - // return true; - -} +function isItAnApple(fruits) { + var appleList = []; + + for (let i = 0; i < fruits.length; i++){ + if (fruits[i] === 'apple'){ + appleList.push(true); + } else { + appleList.push(false); + } + } return appleList; + } + /* From 67fe5a3878af9c619b603f208e5e30b7b4f72d50 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Tue, 7 Apr 2020 18:01:52 -0600 Subject: [PATCH 08/12] getCarInfoByIndex() is complete --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 998ca6f4e..1ed1b624f 100644 --- a/index.js +++ b/index.js @@ -163,7 +163,7 @@ function appleIndex(fruits) { function isItAnApple(fruits) { var appleList = []; - + for (let i = 0; i < fruits.length; i++){ if (fruits[i] === 'apple'){ appleList.push(true); @@ -228,7 +228,8 @@ function get3rdCar(inventory) { * it will return `This is a Lincoln Navigator`. */ function getCarInfoByIndex(inventory, index) { - /* code here */ + var makeModel = inventory[index]; + return `This is a ${makeModel.car_make} ${makeModel.car_model}` } /** From 058aba0b7d57ba070b669ab0759b5f66207e18eb Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Tue, 7 Apr 2020 21:07:45 -0600 Subject: [PATCH 09/12] mvp complete --- index.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 1ed1b624f..d836d76b5 100644 --- a/index.js +++ b/index.js @@ -229,7 +229,7 @@ function get3rdCar(inventory) { */ function getCarInfoByIndex(inventory, index) { var makeModel = inventory[index]; - return `This is a ${makeModel.car_make} ${makeModel.car_model}` + return `This is a ${makeModel.car_make} ${makeModel.car_model}.` } /** @@ -243,8 +243,10 @@ function getCarInfoByIndex(inventory, index) { * For example, if getLastCarInfo is invoked passing the inventory inside /data/inventory.js, * it will return `This is a Lincoln Town Car`. */ -function getLastCarInfo(/* code here */) { - /* code here */ +function getLastCarInfo(inventory) { + var inventoryLength = ((inventory.length) -1); + var lastCar = inventory[inventoryLength]; + return `This is a ${lastCar.car_make} ${lastCar.car_model}.` } /** @@ -256,8 +258,14 @@ function getLastCarInfo(/* code here */) { * (1) an array which is an inventory of cars like the one inside /data/inventory.js. * getModelYears returns an array containing all the 'car_year's in the inventory. */ -function getModelYears(/* code here */) { - /* code here */ +function getModelYears(inventory) { + var carAge = []; + + for (let i = 0; i Date: Wed, 8 Apr 2020 19:49:07 -0600 Subject: [PATCH 10/12] getOldercars Stretch challenge finished --- index.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index d836d76b5..4c9aaa61b 100644 --- a/index.js +++ b/index.js @@ -278,12 +278,15 @@ function getModelYears(inventory) { * (1) an array which is an inventory of cars like the one inside /data/inventory.js. * (2) a number which is the desired car id (see how each car has its own unique id). * getCarInfoById returns a string in the format `This is a {car_make} {car_model} - * + * * For example, if getCarInfoById is invoked with the inventory and the number 1, * it will return `This is a Lincoln Navigator`. */ -function getCarInfoById(/* code here */) { - /* code here */ +function getCarInfoById(inventory, id) { + var carNumber = (id - 1) + var selectedIndex = inventory[carNumber]; + return `This is a ${selectedIndex.car_make} ${selectedIndex.car_model}`; + } /** @@ -300,8 +303,15 @@ function getCarInfoById(/* code here */) { * with a `car_year` which is at most the given desired max year, * in the same order as they appear in the original inventory. */ -function getOlderCars(/* code here */) { - /* code here */ +function getOlderCars(inventory, age) { + var carAges = []; + + for (let i = 0; i < inventory.length; i++){ + var carInfo = Object.values(inventory[i]); + if (carInfo[3] <= age){ + carAges.push(inventory[i]); + } + }return carAges; } /** From 719c2bd883a0d6610e7fc6949d07837482fd6c39 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Wed, 8 Apr 2020 21:52:27 -0600 Subject: [PATCH 11/12] portion of carMaker stretch function complete --- index.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 4c9aaa61b..25ae284cd 100644 --- a/index.js +++ b/index.js @@ -327,8 +327,27 @@ function getOlderCars(inventory, age) { * made by either `Audi` or `Mercedes-Benz` or `Volkswagen` or `BMW`, * in the same order as they appear in the original inventory. */ -function getGermanCars(/* code here */) { - /* code here */ +function getGermanCars(inventory) { + var imports = []; + + for (let i = 0; i < inventory.length; i++){ + var carInfo = Object.values(inventory[i]); + if (carInfo[1] === 'Audi'){ + imports.push(inventory[i]); + } + else + if (carInfo[1] === 'Mercedes-Benz'){ + imports.push(inventory[i]); + } + else + if (carInfo[1] === 'Volkswagen'){ + imports.push(inventory[i]); + } + else + if (carInfo[1] === 'BMW'){ + imports.push(inventory[i]); + } + }return imports; } /** @@ -344,8 +363,13 @@ function getGermanCars(/* code here */) { * (1) causes the odometer in the object to be increased by the distance, * (2) returns the updated value of the `odometer`. */ -function carMaker(/* code here */) { - /* code here */ +function carMaker(miles) { + let car = new Object() + car.odometer = miles; + return car; + + car.drive() = car.odometer = x; + } /// ////// END OF CHALLENGE ///////// From ca54d9a9c5729bcf711ffe7e2fb36a337bbca311 Mon Sep 17 00:00:00 2001 From: Sawyer Pearson Date: Tue, 21 Apr 2020 19:36:34 -0600 Subject: [PATCH 12/12] stuck on last portion of stretch, but MVP & some stretch complete --- index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/index.js b/index.js index 25ae284cd..9d8efdc1b 100644 --- a/index.js +++ b/index.js @@ -367,9 +367,6 @@ function carMaker(miles) { let car = new Object() car.odometer = miles; return car; - - car.drive() = car.odometer = x; - } /// ////// END OF CHALLENGE /////////