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 trialRaul Grigoriu
1,060 PointsHelp on a challenge!
Bummer! Make sure you return a nicely formatted string.
I do not really understand what is not nice in my string really?
Can somebody illuminate me please?
Thank you in advance!:)
def mod(a, b)
puts "The remainder of #{a} divided by {b} is ."
return a % b
end
puts mod(5, 9)
3 Answers
Ryan Huber
13,021 PointsYou are actually not returning your answer as a string. You are printing (puts) a string and then returning just the answer. Try returning the string with your answer:
def mod(a, b)
answer = a % b
return "The remainder of #{a} divided by #{b} is #{answer}."
end
puts mod(5, 9)
Also make sure all your string interpolations have a hash(#) in front of them. Let me know if you still have questions.
Kourosh Raeen
23,733 PointsHi Raul - There should only be a return statement inside the method which returns the sentence "The remainder of a divided by b is c." Use string interpolation inside that string to replace a, b, and c with their actual values and don't display anything.
Raul Grigoriu
1,060 PointsThank for your quick reply Kourosh! :)
Raul Grigoriu
1,060 PointsRaul Grigoriu
1,060 PointsThanks a million Ryan, for now I am good to go but I am most sure in the future...