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 trialyusuf Dibswazit
1,522 Pointswhat am i doing wrong??
func temperatureInFahrenheit(temperature: 30.2) { return temperature
}
// Enter your code below
func temperatureInFahrenheit(temperature: 30.2) {
return temperature
}
1 Answer
Jennifer Nordell
Treehouse TeacherI'm not sure which step you're working on, but I don't even know where you got the 30.2 at all. I see no calculation for a conversion from Celsius to Fahrenheit either and there's nothing to denote the data type of the parameter or the data type for for the returned value. Here's my code for the final step along with some thought processes to reach the solution.
// Enter your code below
func temperatureInFahrenheit(temperature:Double) -> Double {
return temperature * 9 / 5 + 32
}
let fahrenheitTemp = temperatureInFahrenheit(24.0)
- Declare the function temperatureInFahrenheit to take a paramater of type Double and return a value with type Double
- Convert the temperature passed to it from Celsius to Fahrenheit
- Return the Fahrenheit temperature
- Create constant and call the conversion on a temperature
- return the Fahrenheit temperature into the new constant.
Hope that clarifies things!