diff --git a/index.js b/index.js index bdafe4c8b..3f9555071 100644 --- a/index.js +++ b/index.js @@ -35,8 +35,9 @@ function addNumbers(num1, num2) { * the returned value should look like: 'Goodbye, Andy. Have a great day.' * */ -function sayGoodbye(/* code here */) { +function sayGoodbye(name) { /* code here */ + return("Goodbye, "+name +". Have a great day."); } /** @@ -53,8 +54,9 @@ 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(c) { /* code here */ + return Math.round(c*9/5 + 32); } /** @@ -74,8 +76,16 @@ function temperatureCtoF(/* code here */) { * * Hint: You can call your `temperatureCtoF` function from inside `temperatureInF`. */ -function temperatureInF(/* code here */) { +function temperatureInF(t, u) { /* code here */ + var temp; + u=u.toUpperCase(); + if(u=='F'){ + temp = t+"F"; + }else if(u=='C'){ + temp = temperatureCtoF(t).toString()+"F"; + } + return temp; } @@ -95,8 +105,13 @@ function temperatureInF(/* code here */) { * email: "leia@leia.com", * } */ -function makePersonObject(/* code here */) { +function makePersonObject(id, name, email) { /* code here */ + return { + id:id, + name:name, + email:email + } } /** @@ -112,8 +127,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(/* code here */) { +function getName(o) { /* code here */ + return "Hello, my name is "+o.name; } @@ -132,8 +148,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 */) { +function appleIndex(arr) { /* code here */ + for(let i=0; i