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

Sevda Anefi
seal-mask
.a{fill-rule:evenodd;}techdegree
Sevda Anefi
Full Stack JavaScript Techdegree Student 956 Points

hi, this is the code I wrote..

I wrote variations of this and tested them in the console and they worked perfectly fine. However, they won't accept any of those because the console says they're not nicely formatted. How exactly does the programme want me to do it? thanks!

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

mod(7,2)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Wow you're close on this one. But first, you've got a couple of extra lines of code that aren't needed. Secondly, you must follow the instructions to the letter. The instructions explicitly state to return the string... not print the string. It's a picky thing, but it will cause the challenge to fail. Take a look at my solution:

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