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

IOS Function parameters

I'm lost needing some help, with function parameters in swift 3 IOS

functions.swift
// Enter your code below

func getRemainder(ofValue : a, b value: Int){
 return(a%b) 
}

1 Answer

Jorge Solana
Jorge Solana
6,064 Points

Hey Tywan,

You should first review the previous challenge videos and write down good notes of how to call properly to a function. You have there two big problems:

  • 1st, the function parameters (the ones that are received between parenthesis). You first put the name and then the type, so it would be like this: "(a: Int, b: Int)". Then since we are asked to name them to be more specific, we add "value" and "divisor" before them.
  • 2nd, since you're writing a return code, you need to specify the return type at the end of the function declaration like "-> Int"

This is the challenge solution, but try to understand and keep up the good work!

// Enter your code below
func getRemainder(value a: Int, divisor b: Int) -> Int {
  return a%b
}

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

MODERATOR EDIT: Moved response from Comment Section to Answers, as it answers the question posted. It can now be upvoted and/or marked Best Answer.