Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

What am i supposed to do here?

Code Challenge Request: (Let's add some code to the body of the function. Get rid of the existing return statement that's in there and in this task we're going to write out code to take a Celcius temperature value passed in and convert it to Fahrenheit.

To convert from Celcius to Fahrenheit - multiply the value by 9, divide the resulting value by 5 and then add 32.

Once you have the Fahrenheit value, return it from the function.)

What i'v done:

func temperatureInFahrenheit(temperature: Double) -> Double {
   return temperature
}

I do not understand what to do, please simplify the question, give me clues and do NOT tell me the answer unless i reply saying i want one.

Also it is getting REALLY annoying when i have to get help on a code challenge and it doesn't work, REALLY ANNOYING!!!

PS Sorry if this is a pushy question!

2 Answers

Hi Benjamin,

You've got the method skeleton set out nicely. You are passing in a value temperature which is the Celsius value of the temperature. You want to return the Fahrenheit conversion of it.

So, take temperature, multiply by 9, divide the result by 5 then add 32 to it. Return that from the method.

You just need to do the mathematical operations to the incoming temperature variable and return that out of the method.

Make sense?

Steve.

Still not quite sure what to do

I'm just heading back to the office; give me an hour and I'll walk you through a solution. OK?

Steve.

HI Benjamin,

I don't have the link to the code challenge, so I can't test this first. I'll put down what I think should work, based on the above. I'll have to name the function the same as you - the challenge may be happy with that, or it may not.

So, we want a function/method that converts a value that gets passed in from one value to another and returns the new value. The conversion method is given in the challenge as multiply the value by 9, divide the resulting value by 5 and then add 32 so let's do that first.

let fahrenheit = ((celsius * 9) / 5) + 32

Yes, that can be simplified but let's just go with that for this.

I'm sure you can see what comes next. We just need to use you method skeleton that receives the celsius value as a parameter called temperature. That needs converting with the maths above, then returning. You don't need to create a new variable like I did; just return the maths.

Have a go - see if you can finish this off from here. Let me know you get on.

Steve.