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 trialjohannestoikka
335 Pointsi need halp on this
i don't know how to do dis
temperature = 2.0
func temperatureInFahrenheit(temperature){
print(temperature)
}
1 Answer
Alex Millius
iOS Development Techdegree Student 5,468 PointsIt may be confusing since the result of the first part of this challenge doesn't do anything.
Let's take the description of the challenge part by part.
- "Declare a function named temperatureInFahrenheit." -> you have to declare a function, not a variable or a constant:
func temperatureInFahrenheit(){ }
- "The function should take a single input named temperature" -> temperature is the name of the input parameter, not of a variable or a constant. the input are in parentheses:
func temperatureInFahrenheit(temperature ){ }
- " of type Double" -> you have to specify the type of your parameter, in this case, Double:
func temperatureInFahrenheit(temperature : Double){ }
- " and has a return type of Double." -> your function return something, in this case a Double:
func temperatureInFahrenheit(temperature : Double) -> Double { }
- "For now, to make the function pass, simply return the value of the temperature parameter from the function." -> you have to return the function parameter, which is temperature. Since temperature is a Double, it correspond to your return type:
func temperatureInFahrenheit(temperature : Double) -> Double {
return temperature
}