diff --git a/index.js b/index.js index bdafe4c8b..ee890169d 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) { + return(`Goodbye, ${name}. Have a great day.`) } +console.log(sayGoodbye(`Terry`)); /** * ### 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 */) { - /* code here */ +function temperatureCtoF(celsius) { + return(Math.round(celsius*(9/5)+32)); } +console.log(temperatureCtoF(24)); /** * ### Challenge `temperatureInF` * @@ -74,10 +76,11 @@ 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(Math.round(temp*(9/5)+32))+`F`}else{return(`${temp}${unit}`)} +} +console.log(temperatureInF(24,`C`)); /** * ### Challenge `makePersonObject` @@ -95,10 +98,18 @@ function temperatureInF(/* code here */) { * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { - /* code here */ +function makePersonObject(idNum, firstName, address) { + // const object={ + // id:idNum, + // name:firstName, + // address:address +// } + return( + `id:${idNum},\nname:${firstName},\nemail:${address},` + ) + } - +console.log(makePersonObject(5680,`Terry Edwards Jr`,`terryedwardsjr113@gmail.com`)); /** * ### Challenge `getName` * @@ -112,11 +123,15 @@ 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() { + const exObject={ + id: 5680, + name:`Terry`, + email:`terry@terry.com` +}; + return(`Hello, my name is `+exObject.name) } - - +console.log(getName()); /** * ### Challenge `appleIndex` * @@ -132,10 +147,11 @@ 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() { + let array=[`orange`, `grape`,`apple`, `bananan`, `mango`] + return(array.indexOf(`apple`)) } - +console.log(appleIndex()) /** * ### Challenge `isItAnApple` * @@ -151,13 +167,13 @@ function appleIndex(/* code here */) { * 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(array) { + +const fruits=[ 'orange', 'apple', 'banana', 'apples', 'apple', 'mango' ]; +for (i=0; i