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

ahmed aboukoura
ahmed aboukoura
1,345 Points

ruby def statement

def statement

ruby.rb
def check_speed(car_speed)
  if car_spped >= 40 && car_sped >= 50
    puts "safe"
  else
    puts "unsafe"
end
  check_speed(50)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I'm going to give a series of hints and we'll see if you can get it working with these.

  • On line 2 you've misspelled car_speed twice
  • On line 2 you have a logic flaw. You're checking to see if the car's speed is greater than or equal to 40 and greater than or equal to 50. It should be less than or equal to 50.
  • You're printing your strings when you should be using the return statement
  • Your if/else block needs its own end statement
  • You do not need to call the function. Treehouse will call it for you.

I hope you can get it with just these hints, but let us know if you need more help! :sparkles:

ahmed aboukoura
ahmed aboukoura
1,345 Points

oh i got it , thanks you so much :) , appreciated it