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

I can't my coding error

It keeps returning syntax errors

def check_speed(car_speed)
  if (car_speed >= 40) && (car_speed is <= 50)
    puts "safe"
    puts "unsafe"

2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 145,631 Points

Hey Ben,

In addition to Ari's point of the missing end, there are also two other errors that will prevent you from passing.

  1. The instructions explicitly ask to return the strings, but you are using puts.
  2. In the if conditional, the second part, you have the word "is" in there for some reason. It should read like the first part (no "is").

Fix up what Ari pointed out, and correct these two, and the challenge will pass.

Keep Coding! :) :dizzy:

Ari Misha
Ari Misha
19,274 Points

Hiya Ben! You forgot to close your "if" statement with "end" keyword. Do that and you're good to go. (: