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 trialpogtynmsax
4,083 PointsHow do I use function to convert from Celsius to Fahrenheit?
How do I use function to convert Celsius to Fahrenheit? The temperature must be of type Double and the formula to convert Celsius to Fahrenheit is by multiplying the value of Celsius by 9, then dividing the result by 5 and then add 32.
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
let Celsius = 10.0
let fahrenheit = (10.0 * 9.0) / 5.0 + 32.0
return fahrenheit
}
1 Answer
Alexander Davison
65,469 PointsThe challenge didn't ask you to make a variable called Celcuis
.
You should be multiplying the temperature
argument by 9 and dividing 5 etc.
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
let fahrenheitTemperature = temperature * 9 / 5 + 32
return fahrenheitTemperature
}
If you fix that issue you should be fine :)
~Alex
Got questions? Please ask below
pogtynmsax
4,083 Pointspogtynmsax
4,083 PointsIt's proper syntax. Thanks Alex
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsNo problem :)