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 Else challenge

Ruby Oper

what am i doing wrong?

ruby.rb
car_speed = 55
speed_limit = 60
too_fast = true
if car_speed > 60
else
  too_fast = false
  if car_speed < 55
  end
# Write your code here

1 Answer

Hi Sara,

You need to replace 60 to variable name ("speed limit"). You could write if the car speed (55) is less than speed limit (60), it should set true, otherwise if car speed is more than speed limit that would be false.

Modify your code, see below:

car_speed = 55
speed_limit = 60

if car_speed > speed_limit
  too_fast = true
else
  car_speed < speed_limit
  too_fast = false
end

Or either way for much easier to read like elsif shortcut.

car_speed = 55
speed_limit = 60

# Write your code here
if car_speed > speed_limit
   too_fast = true
elsif car_speed < speed_limit
  too_fast = false 
end

Hope that helps. :)