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?

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

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 144,827 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: