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

Sebastian Fernandez
Sebastian Fernandez
2,413 Points

What is a module?

Hi!, I stuck in this exercise because, what is a module?

pls Help!!

functions.swift
// Enter your code below
func getRemainder(value a:Int, divisor b:Int ) -> Int {
    let modulo = a / b
    return modulo
}
Michael Hulet
Michael Hulet
47,913 Points

Can you clarify what you're asking a bit? You ask about what a module is, but your code implies that you mean that you're wondering what the modulo operator (%) does, and these are 2 entirely disparate and unrelated concepts in Swift

1 Answer

andren
andren
28,558 Points

The modulo operator (technically called the remainder operator in Swift) was covered in the Arithmetic Operators video back in the Swift Basics course.

But to offer a quick recap, it looks like the percentage symbol % and gives you the remainder of dividing two numbers. So 4 % 3 for example would result in 1.

All you need to change in your code to pass the task is to replace the / symbol with %.