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 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,323 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