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 trialIaqu lukaku
Courses Plus Student 868 PointsI don't understand the question
what will be the answer ?
// Enter your code below
func getRemainder(a: Int, b: Int) -> Int {
return a%b
}
var value = 10
var divisor = 2;
getRemainder(a: value, b: divisor)
1 Answer
Jonathan Ruiz
2,998 PointsHi iaqu the main thing would be to look at the function when you have parameters. They can either have one or two names for a single parameter. If there is two names for one parameter then you have an external name and a local name for the parameter. You call the external name when using the function and you use the internal name inside the function.
func getRemainder(a: Int, b: Int) -> Int {
return a % b
// the return statement must have these values spaced out like so
// you need to add an external name of value to the parameter a of type Int
// for your second parameter b you need an external name divisor
}
// this is how it would look like
func getRemainder(value a: Int, divisor b: Int) - > Int {
// value is the external name used when we call the function, a is the local name we are using below inside the function
//for the return statement. Think of it this way the local name is going to be the value the user puts into the function when
//we call it in this problem its type Int
//the divisor is the external name and b is the local name for the second parameter
return a % b
}
hope this helps