Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Operators and Control Structures Ruby Control Structures Elsif challenge

Seth Schwartz
Seth Schwartz
3,108 Points

Code not working

Using an "elsif" statement, modify the code below to check whether or not the car_speed is equal to the speed_limit. If it is, set the variable "going_speed_limit" to true. My code is as follows:

car_speed = 55 speed_limit = 55

if car_speed < speed_limit too_fast = false elsif car_speed == speed limit going_speed_limit = true else too_fast = true end

ruby.rb
car_speed = 55
speed_limit = 55

if car_speed < speed_limit
  too_fast = false
elsif car_speed == speed limit 
  going_speed_limit = true
else
  too_fast = true
end

1 Answer

Ari Misha
Ari Misha
19,274 Points

Hiya Seth! You're almost there , just replace "speed limit" with "speed_limit" in your "elsif" block. If it still doesnt pass , here is the code for your reference:

car_speed = 55
speed_limit = 55

if car_speed < speed_limit
  too_fast = false
elsif car_speed == speed_limit
  going_speed_limit = true
else
  too_fast = true
end