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 trialClifford Stiber
1,343 PointsWhat is wrong with my code? Surely I solved the questions of what is the remainder of a divided by b is c?
def mod(a, b) c = a % b puts "The remainder of #{a} divided by #{b} is #{c}:"
end puts mod(3, 5)
def mod(a, b)
c = a % b
puts "The remainder of #{a} divided by #{b} is #{c}:"
end
puts mod(3, 5)
2 Answers
jcorum
71,830 PointsClifford, very close. But it needs to return the string, not display it. You can also just calculate the remainder in the string, rather than create a new variable:
def mod(a, b)
#write your code here
return "The remainder of #{a} divided by #{b} is #{a % b}."
end
Also, they didn't ask you to call the method.
Clifford Stiber
1,343 PointsThanks!
rsvuwipwnt
6,690 PointsHello, remove the "puts" in your mod method, this will mean the method returns the string instead of puts it, so the result of that method IS a string which effectively you can do all sorts of string methods on
Clifford Stiber
1,343 PointsClifford Stiber
1,343 PointsThanks Sam