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 trialSarah Flynn
4,466 PointsI need help finding an answer that treehouse will accept for this question about string interpolation and ruby.
Here's the quiz question from Ruby Basics. I have code that seems to provide a working solution to this but Treehouse will not accept my answer. What am I missing here?
Quiz question:
In the previous challenge, we wrote a method that returned the remainder of two arguments when divided. That's cool, but it would be nicer if the method returned the remainder in a nice full sentence. Use string interpolation to return the remainder inside the sentence “The remainder of a divided by b is c.” where a is your “a” variable, b is your “b” variable, and c is the value of a % b.
My code:
def mod(a, b)
#write your code here
c = a % b
puts "The remainder of #{a} divided by #{b} is #{c}."
end
puts mod(5, 3)
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Sarah,
Your code is correct, it's just not what the challenge asked for, and challenges are very strict and very picky. For this challenge, it asks for you to use "string interpolation to return" ... Note the keyword return. You are using puts
. Just change that puts
to return
and you're all good to go. :)
Keep Coding!
Sarah Flynn
4,466 PointsI just figured that out moments before seeing your comment. Thank you!!
Sarah Flynn
4,466 PointsSarah Flynn
4,466 PointsI figured it out. It seems all I did wrong was use puts instead of return. With that change I was able to move forward to the next video.