Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift 2.0 Functions Functions in Swift 2.0 Recap: Functions

yusuf Dibswazit
yusuf Dibswazit
1,522 Points

what am i doing wrong??

func temperatureInFahrenheit(temperature: 30.2) { return temperature


// Enter your code below
func temperatureInFahrenheit(temperature: 30.2) {
  return temperature 


1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

I'm not sure which step you're working on, but I don't even know where you got the 30.2 at all. I see no calculation for a conversion from Celsius to Fahrenheit either and there's nothing to denote the data type of the parameter or the data type for for the returned value. Here's my code for the final step along with some thought processes to reach the solution.

// Enter your code below
func temperatureInFahrenheit(temperature:Double) -> Double {
  return temperature * 9 / 5 + 32

let fahrenheitTemp = temperatureInFahrenheit(24.0)
  1. Declare the function temperatureInFahrenheit to take a paramater of type Double and return a value with type Double
  2. Convert the temperature passed to it from Celsius to Fahrenheit
  3. Return the Fahrenheit temperature
  4. Create constant and call the conversion on a temperature
  5. return the Fahrenheit temperature into the new constant.

Hope that clarifies things!