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

Taylor Poindexter
Taylor Poindexter
1,047 Points

Treehouse saying string isn't formatted correctly, but it is

So I wrote this code for the challenge:

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

mod(12,4)

Treeehouse keeps saying that my string isn't formatted correctly, but when I run it through the workspace, it returns exactly what it should: "The remainder of 12 divided by 4 is 0".

1 Answer

Hi Taylor,

The challenge wants you to return the string rather than output it with puts

Also, it's looking for an exact match on the string. The example string has a period at the end of the sentence and you're missing that.

Try fixing those 2 things and see if that gets you past it.

Taylor Poindexter
Taylor Poindexter
1,047 Points

You were spot on. Thank you so much, Jason!