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

Function Parameters

Hey guys, Could you please help me with checking what is wrong with my code? The compiler is saying that I have to use the right local and external names when I am sure that I am using the right ones.

Thanks.

functions.swift
// Enter your code below
func getRemainder(valueA: Int, divisorB: Int) -> Int {
valueA % divisorB

return getRemainder
}

1 Answer

Thomas Dobson
Thomas Dobson
7,511 Points

Hi Han,

You were pretty close. See the below Explanation:

// Enter your code below
func getRemainder(value a: Int, divisor b: Int) -> Int //The first input has a external input of value, and internal of a
                                                       //The second input has external input of divisor, and internal of b
{
    return a % b //use the internal inputs within the function. Keeps it short and sweet.
}

let result = getRemainder(value: 10, divisor: 3) //Use the external inputs when calling the function.
                                                 //The well named function and inputs make it clear exactly what this 
                                                 //function call is doing.

I hope this helps

thanks so much!