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 Logical Operators The And (&&) Operator

Simon Goldman
Simon Goldman
1,028 Points

stuck

im not sure what part of my code is wrong??

ruby.rb
def check_speed(car_speed)
end 
  if (check_speed >= 40) && (check_speed <=50)
    return "safe"
  else 
    return "unsafe" 
end

1 Answer

Amir Eskandari
Amir Eskandari
9,153 Points

Hi Simon,

You are really close, I'm just noticing two small issues:

1) Make sure you use the parameter name inside the method, not the method name (use car_speed instead of check_speed in your conditions).

2) Double check line 2. It looks like you have an "end" statement there by mistake - that should be at the very bottom of your code. You need 2 "end" statements, one at the end of the if/else loop and one at the end of the method.

Let me know if that helps or if you have any other questions!