iOS Functions in Swift Functions in Swift Recap: Functions

Recap: Functions

Hi guys, I still do not understand how I am supposed to do this task. The task keeps telling me that I have to perform the correct operation of the correct value, while I think that I have done the right operation and the correct value. Can someone help? Thanks.

functions.swift
// Enter your code below
func temperatureInFahrenheit(temperature: Double) -> Double { 
temperature =((temperature*9)/5)+43





}

2 Answers

Mikis Woodwinter
Mikis Woodwinter
44,915 Points

Hey Han,

The purpose of that function is to take a number as input that represents a given temperature in Celsius and convert that number into another number that represents the same temperature in Fahrenheit. After the conversion, you want to return the Fahrenheit value as the output of the function. Currently, you're not returning anything.

Hi Mikis, I know I am supposed to do that, but I just dont know the code for writing that. Do you have any ideas?

Hey Mikis, I am still stuck on the challenge. This is my code after my edits:

func temperatureInFahrenheit(temperature temperature: Double) -> Double { temperature = ((temperature * 9) / 5) + 43 return temperatureInFahrenheit(temperature: 30.00)

} Now when I check the compiler, it says for me to "Make sure you're performing the correct temperature conversion calculation within the body of the function." But, I only have one constant in the function, and it is "temperature". So, I just can't seem to figure out how I got it wrong because I only have one constant.

Hey Mikis, I am still stuck on the challenge. This is my code after my edits:

func temperatureInFahrenheit(temperature temperature: Double) -> Double { temperature = ((temperature * 9) / 5) + 43 return temperatureInFahrenheit(temperature: 30.00)

} Now when I check the compiler, it says for me to "Make sure you're performing the correct temperature conversion calculation within the body of the function." But, I only have one constant in the function, and it is "temperature". So, I just can't seem to figure out how I got it wrong because I only have one constant.