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 Operators and Control Structures Ruby Control Structures The Ruby Else Statement

David Legault
David Legault
1,543 Points

Cant solve the "Else challenge"

If anyone can help me. I can't figure our how to add an else statement that returns false with my "too_fast" variable.

The challenge is " Set a variable called "too_fast" equal to "true" if the car_speed is faster than the speed_limit and "false" if the car_speed is less than the speed_limit. "

car_speed = 55
speed_limit = 60
too_fast = true

if car_speed > speed_limit
  puts "#{too_fast}"
else         # ?????????????????????

end

3 Answers

Grace Kelly
Grace Kelly
33,990 Points

Hi David, what you have done is try to output a string, which is not what we want. The challenge requires you to create a variable called "too_fast" and give it the value true if the car_speed is faster than the speed_limit. To do this we do the following:

if car_speed > speed_limit
  too_fast = true #create a variable and set the value to true
end

Now applying this knowledge you can then create the else statement and set the too_fast variable to false, hope that helps!!

David Legault
David Legault
1,543 Points

Thanks this helps me a lot ! I really need to focus on what is asked in the question :-)

I don't think it's you. I think it's the instructor needing to be more clear when writing the question.

Treehouse. Could you please ask Grace Kelly to re-write all of your test/challenge questions? So many of your test questions - the wording requires a translation. In other words, you're not wording the questions in a comprehensible manner to the student. I spend hours upon hours simply trying to understand what's being asked. More often than not they range from non-sentences of jargon not used during the lesson to sentences with some different jargon used during the lesson mixed with jargon never mentioned in the lesson.