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

Viraj Kokane
Viraj Kokane
17,531 Points

Please Help !!!

It gives me an error when I type the code...

ruby.rb
def check_speed(car_speed)
  # write your code here
  if (car_speed >= 40) && (car_speed <= 50)  
    puts "safe"
  else
    puts "unsafe"
  end

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Viraj,

You have one syntax error -- You are missing an end statement for the function.

Also, the challenge asks you to return the value "safe" or "unsafe." You are using puts instead.

Add an end and change puts to return and you're good to go.

Keep Coding! :)

Viraj Kokane
Viraj Kokane
17,531 Points

Just Figured it out !

def check_speed(car_speed)
  # write your code here
  if (car_speed >= 40) && (car_speed <= 50)  
    return "safe"
  else
    return "unsafe"
  end 
end
Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Glad you figured it out. You posted a bit quicker than I. lol...

Viraj Kokane
Viraj Kokane
17,531 Points

Hey Jason I tried using The marksheet reference to do so using the backticks but was not able to do so. Please give me some idea

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

You did it right, you just need one more enter/return between the top sentence and the code block (there needs to be a space).

I edited your answer to show this. If you go and click 'edit answer' on your answer, you will see what I mean.

:)

Viraj Kokane
Viraj Kokane
17,531 Points

Thank You Jason Anders ! :)