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 Functions in Swift Functions in Swift Recap: Functions

How do I use function to convert from Celsius to Fahrenheit?

How do I use function to convert Celsius to Fahrenheit? The temperature must be of type Double and the formula to convert Celsius to Fahrenheit is by multiplying the value of Celsius by 9, then dividing the result by 5 and then add 32.

functions.swift
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
      let Celsius = 10.0
      let fahrenheit = (10.0 * 9.0) / 5.0 + 32.0
      return fahrenheit
}

1 Answer

The challenge didn't ask you to make a variable called Celcuis.

You should be multiplying the temperature argument by 9 and dividing 5 etc.

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

If you fix that issue you should be fine :)

~Alex

Got questions? Please ask below :smile:

It's proper syntax. Thanks Alex

No problem :)