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 trialGregory Drew
938 PointsWhy isn't this working?
def mod(a, b) #write your code here puts "The reminder of #{a} divided by #{b} is: " return a%b end
puts mod(12,8)
def mod(a, b)
#write your code here
puts "The reminder of #{a} divided by #{b} is: "
return a%b
end
puts mod(12,8)
3 Answers
Steven Parker
231,269 PointsHere are a few hints:
- you need to build the answer into the string along with the arguments
- you should return the string, not print it out
- return the result as the string, not separately as a value (I know, this seems a bit odd)
- the task is only to create the method, not call it
- check the spelling of "reminder" (remainder)
Gregory Drew
938 PointsI tried this, still not working: ''' def mod(a, b) puts "The remainder of #{a} divided by #{b} is " return a%b end '''
Alan Matthews
10,161 PointsThis is the overall correct method below, however you need to add some code on the commented out line to interpolate c in the string. You need to specifically return
the string instead of using puts
or print
. In Ruby, you normally don't need to add the return
since Ruby will return the last expression evaluated in a method. But in order to pass the challenge, you need return
.
def mod(a, b)
#write your code here
return "The remainder of #{a} divided by #{b} is #{c}."
end