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

Modifying the valid command

I think im super close. Using the && function

ruby.rb
def valid_command?(command)
  if answer = (y) &&(yes) && (Y) && (YES)
    command = "true"
  end
end

1 Answer

Nathan Williams
seal-mask
.a{fill-rule:evenodd;}techdegree
Nathan Williams
Python Web Development Techdegree Student 6,851 Points

Couple issues here, but you're close. You want to test for one of several conditions using the "or" (||) operator, and each condition is using the equality comparison operator "==" (note that you're missing an =, and doing assignment instead).

The answer they're looking for, based on the section you're in, is something like:

def valid_command?(command)
  if (command == 'y' || command == 'Y' || command == 'yes' || command == 'YES')
    true
  else
    false
  end
end

You could also kind of cheat a little by using a different method, like Array#include? shown below, but they're actually testing you on the above.

def valid_command?(command)
  %w( y Y yes YES ).include? command
end

Make sense?