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 Or (||) Operator

not sure what im doing wrong for the OR operator

def valid_command?(command)
  if (valid_command == y) || (valid_command == yes) || (valid_command == Y) || (valid_command == YES)
  return true
end

Moderator Edit: Added Markdown for code readability

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

OK, so there are a few things you need to do here:

1) make sure the name of the variable inside the method is the same as the name of the argument that was passed into the method. command was passed, and inside the method you are using valid_command, which does not exist.

2) make sure that you are comparing with strings, not variable names - y is a variable name, 'y' is a string - what does the task tell you to do?

3) you can move the return statement into the from of the whole thing, like this: return true if ...

4) you can get rid of all the ( )