iOS Functions in Swift Adding Power to Functions Function Parameters

Aryaman Dhingra
Aryaman Dhingra
3,536 Points

Swift functions confusing me

I cannot understand where I'm going wrong. Please help debug my code.

// Enter your code below

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

1 Answer

28,375 Points

The issue is that you have the local and external parameter names the wrong way around. External parameter names comes first then the local name.

So you have to switch the names around like this:

// external and local name swapped
func getRemainder(value a: Int, divisor b: Int) -> Int {
  // value and divisor renamed a and b due to name change above
  return (a % b)