iOS Functions in Swift Adding Power to Functions Function Parameters

john vallone
john vallone
890 Points

Using functions

I declared my function... named my parameters (both internal and external)... returned an integer... setup my modulo equation... and returned the "remainderOfValue".

Then I called the function getRemainder.

It works in Xcode and delivers "2" with no errors but still seems to be incorrect here. Just checking to see if anyone can help. Thank you.

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

getRemainder(a: 6, b: 4)

1 Answer

Logan R
Logan R
22,557 Points

You're super close! You have your names flip-flopped. It should instead be:

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

getRemainder(value: 6, divisor: 4)

The first part is the name of the named parameter, the second part is the local variable name.

john vallone
john vallone
890 Points

:).... Thank you Logan!

Logan R
Logan R
22,557 Points

Not a problem! If you have any further issues or questions, feel free to post them on the forums :D