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 trialCarolyn Buck
4,067 Pointswhen i put this into workspace consule it works WTF?
the code works in the workspaces and prints out the correct stuff but it says im not formatting it correctly?
def mod(a, b)
puts "The remainder of the divided by #{b} is #{a % b}."
return a % b
end
mod(2, 3)
2 Answers
Jarold Wong
7,766 PointsThe challenge is expecting you to return the string rather than putting it in the console.
Instead of puts
, just return
the string. Make sure to double check the format for the string.
Piotr Misiopecki
Courses Plus Student 10,421 PointsTry this:
def mod(a, b)
c = a % b
string = "The remainder of #{a} the divided by #{b} is #{c}."
string
end
Ken jones
5,394 PointsRuby has implicit returns so the string variable in your answer is unnecessary here Pitor. You could refactor this to be much neater like this ->
def mod(a, b)
"The remainder of #{a} divided by #{b} is #{a % b}."
end