iOS Functions in Swift Functions in Swift Recap: Functions

Kellington Chidza
Kellington Chidza
866 Points

To convert from Celcius to Fahrenheit - multiply the value by 9, divide the resulting value by 5 and then add 32.

Once you have the Fahrenheit value, return it from the function.

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

1 Answer

kjvswift93
kjvswift93
13,433 Points

You are creating another function with the same name. Delete the first function in your code and it should pass challenge # 2.

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

}
let fahrenheitTemp = temperatureInFahrenheit(temperature: 24.0)