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 trialTanner Shelton
iOS Development Techdegree Student 1,136 PointsWhy is fahrenheitTemp not returning my results?
func temperatureInFahrenheit(temperature: Double) -> Double {
let fahrenheitTemp = (temperature * 9)/5 + 32
return fahrenheitTemp
}
let temperature = 24.0
Moderator edit: added Markdown so the code can be read in the Community. Please, when posting code, refer to the Markdown Cheatsheet located above the Post button
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Tanner,
It looks like you are trying to assign a value to the parameter instead of calling the function with a parameter passed in, as the instructions are stating. Remember when calling a function it is the function name
with the parameter(s) passed into the parenthesis => functionName(parameter)
Have a look over the part of the code where you should be calling the function. The rest looks good!
Keep Coding! :)
Tanner Shelton
iOS Development Techdegree Student 1,136 PointsThanks for the help Jason. Figured it out a little bit ago. Much appreciated!
Tanner Shelton
iOS Development Techdegree Student 1,136 PointsTanner Shelton
iOS Development Techdegree Student 1,136 PointsCan you elaborate? I'm doing this the same way it was done in the demonstration videos.
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsYour last line:
let temperature = 24.0
is trying to assign a hard-coded value to the variable, but the instructions specifically state to store the "return of the function call to the variable".So, you need to call the function with the value of 24.0 passed in, and then store that into the variable named
fahrenheitTemp
not temperature:let fahrenheitTemp = temperatureInFahrenheit(temperature: 24.0)