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 trialLana Wong
3,968 PointsFunctions match the directions correctly. What am I doing wrong?
The complier said:
Bummer! Make sure the operation you're carrying out in the body of the function matches the directions and correctly converts a Celcius temperature to Fahrenheit
My code did not work. What is wrong?
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
let celeciusTemperature = temperature * 9/5 + 32
return temperature
}
1 Answer
andren
28,558 PointsYou are returning the wrong thing, the temperature variable contains the temperature that was passed in to the function, you want to return the converted temperature, which you have stored in the celeciusTemperature constant.
Though it's also worth noting that you have somewhat misnamed that constant, your function takes in a temperature in Celsius and converts it to Fahrenheit. The constant you have named celeciusTemperature is the constant that holds the temperature after it has been converted to Fahrenheit, so logically it should be called fahrenheitTemperature.
Like this:
func temperatureInFahrenheit(temperature: Double) -> Double {
let fahrenheitTemperature = temperature * 9/5 + 32
return fahrenheitTemperature
}
That code will allow you to pass the second task.