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

ahmed aboukoura
ahmed aboukoura
1,345 Points

ruby def statement

def statement

def check_speed(car_speed)
  if car_spped >= 40 && car_sped >= 50
    puts "safe"
    puts "unsafe"

2 Answers

Jennifer Nordell
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