From 9279cebff46a3d013b49f8ccf2f3d5e9f5c5017b Mon Sep 17 00:00:00 2001 From: Kevin Gallardo Date: Tue, 24 Mar 2020 15:20:51 -0600 Subject: [PATCH 1/6] unfinished --- index.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index bdafe4c8b..ad0a4be81 100644 --- a/index.js +++ b/index.js @@ -35,9 +35,10 @@ 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) { + console.log('Goodbye, ' ${name} '.' 'Have a great day.') } +sayGoodbye(Kevin); /** * ### Challenge `temperatureCtoF` @@ -53,10 +54,11 @@ function sayGoodbye(/* code here */) { * 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 */) { +function temperatureCtoF(celsius) { +return math.round(celsius * 9/5 + 32); /* code here */ } - +console.log(temperatureCtoF(42)); /** * ### Challenge `temperatureInF` * @@ -112,8 +114,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(name) { + console.log 'hello, my name is ' ${name}'.'; } @@ -132,8 +134,9 @@ function getName(/* code here */) { * passing in [ 'orange', 'grape', 'apple', 'banana', 'mango' ] as the argument, * the returned value should be: 2. */ -function appleIndex(/* code here */) { - /* code here */ +function appleIndex(index) { + appleIndex.indexOf('apple'); + return appleIndex } /** @@ -152,7 +155,7 @@ function appleIndex(/* code here */) { * the returned value should be: [ false, true, false, false, true, false ]. */ function isItAnApple(/* code here */) { - /* code here */ + console.log(isItAnApple.includes('apple')); } From 6192306df648aa708c4e6ecc081784c4913aad1b Mon Sep 17 00:00:00 2001 From: Kevin Gallardo Date: Tue, 24 Mar 2020 15:32:56 -0600 Subject: [PATCH 2/6] final --- index.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index ad0a4be81..afb1bf3b7 100644 --- a/index.js +++ b/index.js @@ -115,7 +115,7 @@ function makePersonObject(/* code here */) { * the returned value should look like `Hello, my name is Leia`. */ function getName(name) { - console.log 'hello, my name is ' ${name}'.'; + console.log `hello, my name is ${name}.`; } @@ -212,8 +212,26 @@ function get3rdCar(inventory) { * For example, if getCarInfoByIndex is invoked with the inventory and the number 0, * it will return `This is a Lincoln Navigator`. */ -function getCarInfoByIndex(inventory, index) { - /* code here */ +var inventory = [ + { id: 1, car_make: "Lincoln", car_model: "Navigator", car_year: 2009 }, + { id: 2, car_make: "Mazda", car_model: "Miata MX-5", car_year: 2001 }, + { id: 3, car_make: "Land Rover", car_model: "Defender Ice Edition", car_year: 2010 }, + { id: 4, car_make: "Honda", car_model: "Accord", car_year: 1983 }, + { id: 5, car_make: "Mitsubishi", car_model: "Galant", car_year: 1990 }, + { id: 6, car_make: "Honda", car_model: "Accord", car_year: 1995 }, + { id: 7, car_make: "Smart", car_model: "Fortwo", car_year: 2009 }, + { id: 8, car_make: "Audi", car_model: "4000CS Quattro", car_year: 1987 }, + { id: 9, car_make: "Ford", car_model: "Windstar", car_year: 1996 }, + { id: 10, car_make: "Mercedes-Benz", car_model: "E-Class", car_year: 2000 }, + { id: 11, car_make: "Infiniti", car_model: "G35", car_year: 2004 }, + { id: 12, car_make: "Lotus", car_model: "Esprit", car_year: 2004 }, + { id: 13, car_make: "Chevrolet", car_model: "Cavalier", car_year: 1997 }, + { id: 14, car_make: "Dodge", car_model: "Ram Van 1500", car_year: 1999 } + +] + + function getCarInfoByIndex(inventory, index) { + console.log `This is a ${car_make} ${car_model}` } /** @@ -227,7 +245,7 @@ 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 */) { +function getLastCarInfo(/* code here */){ /* code here */ } From bf69f58f6e219a648c7723846afbd265b815c515 Mon Sep 17 00:00:00 2001 From: Kevin Gallardo Date: Wed, 25 Mar 2020 09:05:15 -0600 Subject: [PATCH 3/6] ongoing --- index.js | 49 +++++++++++++++++------- package-lock.json | 95 ++++++++++++++++++++++++----------------------- 2 files changed, 84 insertions(+), 60 deletions(-) diff --git a/index.js b/index.js index afb1bf3b7..42b7b001e 100644 --- a/index.js +++ b/index.js @@ -36,9 +36,9 @@ function addNumbers(num1, num2) { * */ function sayGoodbye(name) { - console.log('Goodbye, ' ${name} '.' 'Have a great day.') + return `Goodbye, ${name}. Have a great day.` } -sayGoodbye(Kevin); + /** * ### Challenge `temperatureCtoF` @@ -55,7 +55,7 @@ sayGoodbye(Kevin); * Hint 2: There is a very easy way to round numbers in JS. Do a google search to find out how. */ function temperatureCtoF(celsius) { -return math.round(celsius * 9/5 + 32); +return Math.round(celsius * 9/5 + 32); /* code here */ } console.log(temperatureCtoF(42)); @@ -76,10 +76,17 @@ console.log(temperatureCtoF(42)); * * Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`. */ -function temperatureInF(/* code here */) { - /* code here */ -} +function temperatureInF(temp, unit) { + if(unit==='C'){ + return temperatureCtoF(temp) + 'F' + } + else{ + return temp + unit + + } +} +temperatureInF(88, 'F'); /** * ### Challenge `makePersonObject` @@ -135,8 +142,11 @@ function getName(name) { * the returned value should be: 2. */ function appleIndex(index) { - appleIndex.indexOf('apple'); - return appleIndex + for (let i=0; i Date: Wed, 25 Mar 2020 13:26:14 -0600 Subject: [PATCH 4/6] finished what i could --- index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 42b7b001e..92e960969 100644 --- a/index.js +++ b/index.js @@ -104,10 +104,14 @@ temperatureInF(88, 'F'); * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { - /* code here */ +function makePersonObject(id, name, email) { + id: id; + personName:name; + email:email; + return makePersonObject } + /** * ### Challenge `getName` * @@ -121,8 +125,9 @@ 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(name) { - console.log `hello, my name is ${name}.`; +function getName() { + name:name; + } @@ -281,9 +286,7 @@ function getLastCarInfo(inventory) * (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 */ -} + /** * ### Challenge `getCarInfoById` From 3b1dbbcaf268496b1014f232015b8db804dbf1d0 Mon Sep 17 00:00:00 2001 From: Kevin Gallardo Date: Thu, 16 Apr 2020 18:51:53 -0600 Subject: [PATCH 5/6] Finished --- index.js | 106 +++++++++++++++++++++++++++------------------- package-lock.json | 41 ++++++++++++------ package.json | 2 +- 3 files changed, 91 insertions(+), 58 deletions(-) diff --git a/index.js b/index.js index 92e960969..4891e4b2c 100644 --- a/index.js +++ b/index.js @@ -104,11 +104,21 @@ temperatureInF(88, 'F'); * email: "leia@leia.com", * } */ -function makePersonObject(id, name, email) { - id: id; - personName:name; - email:email; - return makePersonObject +function makePersonObject(id, name, email){ + const person ={ + id:id, + name:name, + email:email + } +return person; +/* +// if the top one doesnt work do this +return { + id:id, + name:name, + email:email +} +*/ } @@ -125,11 +135,14 @@ function makePersonObject(id, name, email) { * 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() { - name:name; - + +function getName(name) { + nameOne:name + return `Hello, my name is ${name.name}` + } + /** * ### Challenge `appleIndex` @@ -146,12 +159,13 @@ function getName() { * passing in [ 'orange', 'grape', 'apple', 'banana', 'mango' ] as the argument, * the returned value should be: 2. */ -function appleIndex(index) { - for (let i=0; i Date: Fri, 17 Apr 2020 17:32:07 -0600 Subject: [PATCH 6/6] final v2 --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 4891e4b2c..5026b1530 100644 --- a/index.js +++ b/index.js @@ -338,10 +338,14 @@ function getCarInfoById(inventory, id) { * 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(array, maxYear) { + let oldCars = [] + for(let i=0; i<= maxYear; i++){ + oldCars.push[i] + } + return oldCars } - + /** * ### Challenge `getGermanCars` * * THIS ONE IS A STRETCH GOAL. ATTEMPT IT ONLY AFTER