iOS Functions in Swift Functions in Swift Recap: Functions

Arius Eich
Arius Eich
2,769 Points

Whats wrong? Functions

I'm sure I'm doing something really simple incorrect but what is it?

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

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 145,038 Points

Hi Arius,

Yep... you've got all the pieces there, but just a bit too much and in the wrong place.

The task wants you to return the new value, which is done after the math. You do have the equation there, but it needs to be inside of the return statement. Right now, the way you have it, the compiler just sees a random line that really does nothing, as it is not 'assigned' to a variable or returned to one. Also, while your equation is 'technically' correct, you do not need all those parenthesis. The rules of Mathematics will do the equation in the proper order as it is written here.

So, all you need to do is to move the entire line with the equation inside of the return and remove those extra/unneeded parenthesis (but keep the one around the return statement)

This should get you going, but let me know if you're still stuck.

Keep Coding! :) :dizzy: