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 trialGiovanni Rinaldi
1,104 PointsStuck with celcius to Fahrenheit conversion
I'm not able to code the celcius to Fahrenheit conversion inside my func. Thanks
Giovanni
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double {
let celciusToFahrenheit = (celcius *9)/2 + 32
return celciusToFahrenheit
}
1 Answer
Steve Hunter
57,712 PointsHi there,
You can't use the name celsius
inside your mehtod - it doesn't exist. The method receives a value stored in the variable named temperature
. So, change celsius
to temperature
first.
Next, your maths is a little off - the division is by 5, not 2. Lastly, and this isn't making your answer fail, you can just return the result of the expression, rather than storing it and immediately returning it:
let returnValue = a + b
return returnValue
// or just
return a + b
That should fix it!
Steve.
Giovanni Rinaldi
1,104 PointsGiovanni Rinaldi
1,104 PointsThanks a lot. I've go through my mistakes