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

Tina Maddox
Tina Maddox
28,102 Points

Won't run for challenge but runs in workspaces

My code runs in workspaces/console but states something isn't quite right. Does anyone else see what I am missing?

Hi Tina,

Can you post your code?

Tina Maddox
Tina Maddox
28,102 Points
def mod(a, b)
  #write your code here
  c = a % b
  return "The remainder of #{a} divided by #{b} is: #{c}"
end

puts mod(5, 5)

2 Answers

The code challenge is looking for an exact match on the output string. What you have isn't wrong but not exactly what the code challenge is expecting to get.

The example string has a period at the end which you need to add and you have to take out the colon that you added after "is"

Also, you don't necessarily need to create the extra variable c but it doesn't hurt to do so. You could place the a % b expression directly in the output string.

return "The remainder of #{a} divided by #{b} is #{a % b}."
Tina Maddox
Tina Maddox
28,102 Points

Jason, Thank you! That was driving me nuts. I couldn't figure out what it wanted.
I apologize for not putting my code in earlier. I thought I had. Multi-tasking doesn't go so well sometimes. I appreciate your informative feedback. :)