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!
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
Ben Santen1,998 Points
I can't see why I am not passing this code challenge
It keeps saying try again
def valid_command?(command) if (answer == "y") || (answer == "yes") || (answer == "Y") || (answer == "YES") answer == true end end
Jason AndersTreehouse Moderator 145,826 Points
There are a couple things going wrong here.
- You are comparing a variable
answerto the values, but there is no such variable. The values that would be passed in are being passed to the parameter in the function which is named
command. This is the variable name that you need to be using to compare the values.
- The instructions say to make the method "return true when passed the following values" but you are trying to assign the value (again to a variable that doesn't exist). Here, if the condition passes, all you want the method to do is
return true, not assign or reassign anything. Methods can do all of this; however, this challenge is just looking for the method to return a value ("true" in this case).
If you fix those up, the challenge will pass. :)