iOS Functions in Swift Functions in Swift Recap: Functions

Kellington Chidza
Kellington Chidza
866 Points

Declare a function named temperatureInFahrenheit. The function should take a single input named temperature of type Dou

Declare a function named temperatureInFahrenheit. The function should take a single input named temperature of type Double and has a return type of Double.

func temperatureInFahrenheit(temperature: Double) -> Double { return temperature }

functions.swift
// Enter your code below
KRIS NIKOLAISEN
KRIS NIKOLAISEN
Pro Student 50,933 Points

What you have passes task 1. Are you stuck on task 2?

2 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 50,933 Points

Task 2 wants you to add the math for the temperature conversion. You can add this directly to your previous code:

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