2 Conditions in if statement
ruby
Solution
Rather than an `or` here, you want a logical `&&` (and) because you are trying to find strings which match neither.
if ( !email_address.end_with?("@domain1.com") && !email_address.end_with?("@domain2.com"))
#Do Something
end
By using `or`, if either condition is true, the whole condition will still be false.
Note that I am using `&&` instead of `and`, since it has a higher precedence. Details are well outlined here
From the comments:
You can build an equivalent condition using `unless` with the logical or `||`
unless email_address.end_with?("@domain1.com") || email_address.end_with?("@domain2.com")
This may be a bit easier to read since both sides of the `||` don't have to be negated with `!`.
Problem
I am trying to detect if the email address is not one of two domains but I am having some trouble with the ruby syntax. I currently have this: ``` if ( !email_address.end_with?("@domain1.com") or !email_address.end_with?("@domain2.com")) #Do Something end ``` Is this the right syntax for the conditions?