iOS Functions in Swift Adding Power to Functions Function Parameters

Functions swift code challenge 1

Challenge Task 2 of 2

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.

Bummer! You need to assign the result of the function evaluation to the constant named result

I don't understand the error. I used let to assign the constant result to the function but maybe this is not how it goes.

Thanks.

functions.swift
// Enter your code below
func getRemainder(value a: Int, divisor b: Int) -> (Int) {

  var remainder = a % b

  return remainder
}

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

1 Answer

Matthew Long
Matthew Long
28,356 Points

You did everything correct except the return type isn't what the code challenge is expecting? I copied your code into Xcode, and it still works. That's all I can find "wrong" with your code. It's not usual to use the parentheses as a return type unless you're returning a tuple though. So if you remove the parentheses around (Int) you'll pass the challenge:

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

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