diff --git a/index.js b/index.js index bdafe4c8b..5026b1530 100644 --- a/index.js +++ b/index.js @@ -35,10 +35,11 @@ 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.` } + /** * ### 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` * @@ -74,10 +76,17 @@ 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{ + return temp + unit + + } +} +temperatureInF(88, 'F'); /** * ### Challenge `makePersonObject` @@ -95,10 +104,24 @@ function temperatureInF(/* code here */) { * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { - /* code here */ +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 +} +*/ } + /** * ### Challenge `getName` * @@ -112,10 +135,14 @@ 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) { + nameOne:name + return `Hello, my name is ${name.name}` + } + /** * ### Challenge `appleIndex` @@ -132,8 +159,13 @@ 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(fruit) { + for(let i=0; i