iOS Functions in Swift Adding Power to Functions Function Parameters

Nigel Matheson
PRO
Nigel Matheson
Pro Student 1,166 Points

stuck on this question regarding functions

i know i'm close but just not close enough regarding functions question

functions.swift
// Enter your code below
func getRemainder (a: value, b:divisor) return: Int

2 Answers

tromben98
tromben98
13,272 Points

Hi Nigel!

I think that you should repeat the previous videos in order to learn about return types and parameter names

Best regards, Jonas

// Enter your code below
func getRemainder (value a: Int, divisor b: Int) -> Int {
return a % b
}
Habib Miranda
Habib Miranda
7,320 Points

You are creating a return type the same way you are creating a function parameter. The Parameter of the function (what's inside the parenthesis) require a name. For example:

function nameOfFunc(nameOfParam1: Int, nameOfParam2: Int) {
}

Now in order to add a return type to the function, you simply add the return type without naming it. It looks like you are trying to assign a name to your return. You don't need to name it with the name: Type syntax. You simply need to declare what type it is with the -> Type syntax. See the example:

function nameOfFunc(nameOfParam1: Int, nameOfParam2: Int) -> Int {
     return nameOfParam1 % nameOfParam2
}