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

muna alkhalil
muna alkhalil
2,798 Points

what is wrong with my code?

it looks right to me!

ruby.rb
def check_speed(car_speed, speed_limit)

  if car_speed > speed_limit
    puts "Slow down!"
  else
    puts "Safe travels!"
  end

check_speed(20,30)

2 Answers

andren
andren
28,558 Points

You are missing a end statement. Your code contains a function and an if statement, both of those need to be terminated by a end statement, but there is only one present in the code. If you add another end to the code like this:

def check_speed(car_speed, speed_limit)

  if car_speed > speed_limit
    puts "Slow down!"
  else
    puts "Safe travels!"
  end # This marks the end of the if statement
end # This marks the end of the function

Then your code will work.