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 trialJorge Garcia
6,496 PointsString interpolation
I have no idea how to move on from this. I feel like i've tried everything that I know and it's not doing it.
def mod(a, b)
puts "The remainder of #{a} divided by #{b} is c."
return a % b
end
4 Answers
nulled
1,890 PointsWhat you have is close. This should work:
def mod(a, b)
c = a % b
return "The remainder of #{a} divided by #{b} is #{c}."
end
Kourosh Raeen
23,733 PointsHi Jorge - Instead of displaying the string with puts you need to return it, so change puts to return and remove the other return statement. Also, you need to use string interpolation where you have c in the string. That's where you need to use a%b.
Alexander Davison
65,469 PointsHi, the best way to do it is this:
def mod(a, b)
return "The remainder of #{a} divided by #{b} is #{a % b}."
end
Jorge Garcia
6,496 PointsThat did it!! Thank you all so much!