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 trial

iOS Functions in Swift Adding Power to Functions Function Parameters

I need help! PLS

Here is the question: Now that we have a working function let's use it.

Call the function and pass in a value of 10 for the first parameter and 3 for the second.

Assign the result of the function operation to a constant named result.

functions.swift
func getRemainder(value a: 10, divisor b: 3) -> Int {
     let remainder = a * b
     return remainder
}

1 Answer

Christian Mangeng
Christian Mangeng
15,970 Points

Hi Joshua,

you only need to call the function now. Leave the definition of the function as it is at the end of task 1. In oder to call it, you pass in the arguments for value and divisor, i.e. 10 and 3. For the call of the function only the external names are used (value and divisor), not the local ones (a and b), as they are valid only inside the function. All these operations are performed outside of the function definition. The result of the function call you then assign to the constant result.

func getRemainder(value a: Int, divisor b: Int) -> Int {
     return a % b
}

let result = getRemainder(value: 10, divisor: 3)