From 27cd156ab025aac3fa98729218204f3f5a7e35fb Mon Sep 17 00:00:00 2001 From: dustin Date: Tue, 21 Apr 2020 17:14:42 -0500 Subject: [PATCH 1/6] up and running again --- index.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index bdafe4c8b..08fe10a26 100644 --- a/index.js +++ b/index.js @@ -35,10 +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) { + return ("Goodbye, " + name + ". Have a great day.") } - +sayGoodbye("Andy"); /** * ### Challenge `temperatureCtoF` * @@ -53,10 +53,10 @@ 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 */) { - /* code here */ +function temperatureCtoF(celsius) { +return (Math.round(celsius*9/5+32)); } - +temperatureCtoF(24); /** * ### Challenge `temperatureInF` * @@ -74,10 +74,14 @@ function temperatureCtoF(/* code here */) { * * 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 if (unit == "F") + return temp + unit; } - +temperatureInF(24,"C"); /** * ### Challenge `makePersonObject` @@ -95,9 +99,16 @@ function temperatureInF(/* code here */) { * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { - /* code here */ +function makePersonObject(param1,param2,param3) { + var makePerson ={ + id : param1, + name : param2, + email : param3, + } + return makePerson; } +makePersonObject(5, "Leia", "Leia@leia.com"); + /** * ### Challenge `getName` From 072b27c9215d6e139a1e3e1d3ecea20cdc570ca9 Mon Sep 17 00:00:00 2001 From: dustin Date: Tue, 21 Apr 2020 22:54:56 -0500 Subject: [PATCH 2/6] another one down --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 08fe10a26..b1f523504 100644 --- a/index.js +++ b/index.js @@ -123,10 +123,11 @@ makePersonObject(5, "Leia", "Leia@leia.com"); * 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(para1) { + return "Hello, my name is " + para1.name; +} +getName ( {id: 1, name: 'Leia', email: 'leia@leia.com' }); /** * ### Challenge `appleIndex` From abef5c2d9c5ffaef42a2c26202d5e0c62248604b Mon Sep 17 00:00:00 2001 From: dustin Date: Wed, 22 Apr 2020 08:53:06 -0500 Subject: [PATCH 3/6] i did it all by myself --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b1f523504..fd04e4bed 100644 --- a/index.js +++ b/index.js @@ -144,10 +144,12 @@ getName ( {id: 1, name: 'Leia', email: 'leia@leia.com' }); * passing in [ 'orange', 'grape', 'apple', 'banana', 'mango' ] as the argument, * the returned value should be: 2. */ -function appleIndex(/* code here */) { - /* code here */ +function appleIndex(myArr) { +var fruits = myArr; + var app = fruits.indexOf('apple'); + return app; } - +appleIndex(['orange', 'grape', 'apple', 'banana', 'mango']) /** * ### Challenge `isItAnApple` * From c4201395812d265ce52560a99a445e6cbcf18148 Mon Sep 17 00:00:00 2001 From: dustin Date: Wed, 22 Apr 2020 17:12:48 -0500 Subject: [PATCH 4/6] im so proud of myself, 3 left --- index.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index fd04e4bed..871d1e1c8 100644 --- a/index.js +++ b/index.js @@ -165,8 +165,18 @@ appleIndex(['orange', 'grape', 'apple', 'banana', 'mango']) * 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(arrayBool) { + const newArr = []; + for ( let i = 0 ; i < arrayBool.length ; i++ ) { + if (arrayBool[i] === 'apple'){ + newArr.push (true); + } + else{ + newArr.push (false); + } + + } +return(newArr); } @@ -224,7 +234,9 @@ function get3rdCar(inventory) { * it will return `This is a Lincoln Navigator`. */ function getCarInfoByIndex(inventory, index) { - /* code here */ + const theCar = inventory[index]; + + return `The is a ${theCar.car_make} ${theCar.car_model}` } /** From 4674049f13ac0510a2c12083524c9653eb053043 Mon Sep 17 00:00:00 2001 From: dustin Date: Wed, 22 Apr 2020 17:40:24 -0500 Subject: [PATCH 5/6] last non stretch question --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 871d1e1c8..ac8828390 100644 --- a/index.js +++ b/index.js @@ -250,8 +250,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(carArr) { + const carIn = carArr.length - 1; + const theLast = carArr[carIn]; + return `The is a ${theLast.car_make} ${theLast.car_model}` } /** From cb201bd3a9bfb9e8cda8e5f10eaa7e03b350a61a Mon Sep 17 00:00:00 2001 From: dustin Date: Wed, 22 Apr 2020 20:02:16 -0500 Subject: [PATCH 6/6] finish project --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index ac8828390..1c8ec743c 100644 --- a/index.js +++ b/index.js @@ -265,8 +265,12 @@ function getLastCarInfo(carArr) { * (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(carInventory) { +const yearofcars = [] + for (let i = 0; i > carInventory.length; i++){ + yearofcars.push(carInventory.car_year); + } +return yearofcars; } /**