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

Tanner Hildebrandt
Tanner Hildebrandt
1,820 Points

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

I have assigned the result a constant named result. What am I doing wrong here?

functions.swift
// Enter your code below
func getRemainder(value a: Int, divisor b: Int) -> Int {
let operation = a % b
return operation 
}

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

2 Answers

andren
andren
28,558 Points

When you call the function you should't specify both value and a as parameter names. value is the external label, meaning that is the label you use when you call the function. a is the internal label, meaning that is the one you use within the function. The same is true of divisor and b.

So if you simply remove a and b from the call to the function like this:

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

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

Then your code will work.