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 trialKyle Merrick
3,617 PointsWhat is the answer here? For someone reason, I'm completely stumped on the proper syntax here.
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.
def
puts "The remainder of #{a} divided by #{b} is #{c}:"
end
3 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Kyle,
You're on the right track, but there are a few issues preventing the challenge from passing:
- First, for some reason you have deleted part of the code that was pre-loaded, specifically the method name and definition.
- You are trying to interpolate a value for
c
, butc
is not defined anywhere. The question doesn't want you to create a new variable (although you could), but rather, the challenge wants you to do the calculation inside of the interpolation. - You have a colon at the end of the sentence instead of a period (challenges are very picky).
- The challenge explicitly asks you to
return
the string, but you are usingputs
.
You will need to reset the challenge to get back the deleted code, and with these hints in mind, you should be able to pass the challenge.
Keep Coding! :)
Tobias Jackson
9,758 PointsI don't get it. Can some show how its look like?
Kyle Merrick
3,617 PointsShould look like this,...
def mod(a, b) c = a % b "The remainder of #{a} divided by #{b} is #{c}." end
Tobias Jackson
9,758 Pointsstill says Bummer!
Kyle Merrick
3,617 PointsKyle Merrick
3,617 PointsGot it! Thanks for taking the time to explain it, I really appreciate it. I think looking at it with fresh eyes also helped my cause.