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

For some reason, this won't take the solution I made, yet it seems correct.

I defined a method that should do what the challenge asks for. I also tested it by adding the line of code:

mod(7,3)

... and it said what it was supposed to say.

method.rb
def mod(a, b)
  # get the remainder of a/b and assign it to C
  c=a%b
  puts "The remainder of #{a} divided by #{b} is #{c}." 
end

3 Answers

Shawn Wilson
seal-mask
.a{fill-rule:evenodd;}techdegree
Shawn Wilson
iOS Development Techdegree Student 7,049 Points

David, Try clearing you browsing history, close your browser and try again, I have had these issues in the past as well and that was what resolved it for me. Let me know how it works for you, even try a computer restart after clearing your browser.

Simon Coates
Simon Coates
28,694 Points

it seemed to accept

def mod(a, b)
  # get the remainder of a/b and assign it to C
  c=a%b
  return "The remainder of #{a} divided by #{b} is #{c}." 
end

By return they meant send back, not output to screen.

Something must be wrong. It is rejecting my answer. I am having a similar problem on a code challenge in my JavaScript class as well.

Simon Coates
Simon Coates
28,694 Points

i just copied my code from above and repasted. Passed challenge. Unsure why this wouldn't work for you.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

I also copy/pasted Simon Coates answer into the challenge and also passed. So, it should work.

:dizzy: