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 Loops Ruby Loops Loop Conditionals

Loop Conditionals Challenge Task 1 of 1

I am not sure what to do

loop.rb
# Assume get_answer() is already defined

1 Answer

Start and end the loop:

loop do

end

Now, assign the value of the get_answer() method to the variable "answer". You can put either get_answer() or get_answer:

loop do
  answer = get_answer
end

And last, break the loop with an if statement if the variable "answer" is equal/comparable ("==") to the string e. Make sure you define e as a string by wrapping it in single quotes (the apostrophe character):

loop do 
  answer = get_answer
  break if answer == 'e'
end

Thank you - I kept running in circles because I thought the task asked for answer to be compared to a string in a variable named e, and so not adding the quotation around 'e'