diff --git a/index.js b/index.js index bdafe4c8b..80861986a 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.` } /** @@ -53,8 +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(degree) { + + C = Math.round(degree * 9 / 5) + 32; + return C; } /** @@ -74,8 +76,16 @@ function temperatureCtoF(/* code here */) { * * Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`. */ -function temperatureInF(/* code here */) { - /* code here */ +function temperatureInF(degree,unit) { + C = Math.round(degree * 9 / 5) + 32; + + if (unit === "F") { + + return degree + unit; + } + else { + return C + "F"; + } } @@ -95,8 +105,13 @@ function temperatureInF(/* code here */) { * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { - /* code here */ +function makePersonObject (a, b, c) { + let person = { + id: a, + name: b, + email: c + }; + return person; } /** @@ -112,8 +127,13 @@ 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 (a,b,c) { + let person = { + id: a, + name: b, + email: c + }; + return `Hello, my name is ${person.name}.`; } @@ -132,8 +152,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(a,b,c,d,e) { + + let fruit = [a,b,c,d,e]; + + return fruit.indexOf(c) } /** @@ -150,10 +173,20 @@ function appleIndex(/* code here */) { * For example, if we invoke `isItAnApple` * 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 */ -} + */ +let fruit = [a,b,c,d,e,f]; +function isItAnApple(fruit) { + + for (i = fruit.indexOf[0]; i < fruit.length; i++) { + + if (fruit.indexOf[i]===`apple`) { + return `true`; + } + else { + return `false`; + } + } + }