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 trial

Ruby Ruby Basics (Retired) Ruby Methods Method Returns: Part 2

sarah strange
sarah strange
556 Points

the code is right but the system will not let me continue, keeps saying make sure the string is properly formatted

the code is right not sure why it won't let me proceed

method.rb
def mod(a, b)
  c = a % b
  puts "The remainder of #{a} divided by #{b} is #{c}."
  return c 
end

mod(18, 5)

1 Answer

You did a great job! Code challenges are picky. This should work 100% fine if you run the code in irb or something, but the code challenge expects you to return the string, making puts useless here. Also, the code challenge automatically runs the function so you don't need the

mod(18, 5)

line of code. Try doing that! :)

Here's the complete code:

def mod(a, b)
  c = a % b
  return "The remainder of #{a} divided by #{b} is #{c}."
end

Good luck! ~Alex

Can you give me a best answer please so that this question won't be in the "Unanswered Questions" section of the Community? Thank you very much! ~Alex