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,375 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.