iOS Functions in Swift Functions in Swift Recap: Functions

Stuck with celcius to Fahrenheit conversion

I'm not able to code the celcius to Fahrenheit conversion inside my func. Thanks


// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
let celciusToFahrenheit = (celcius *9)/2 + 32
return celciusToFahrenheit

1 Answer

Steve Hunter
Steve Hunter
Treehouse Moderator 57,626 Points

Hi there,

You can't use the name celsius inside your mehtod - it doesn't exist. The method receives a value stored in the variable named temperature. So, change celsius to temperature first.

Next, your maths is a little off - the division is by 5, not 2. Lastly, and this isn't making your answer fail, you can just return the result of the expression, rather than storing it and immediately returning it:

let returnValue = a + b
return returnValue

// or just

return a + b

That should fix it!


Thanks a lot. I've go through my mistakes