tags:

views:

93

answers:

3

is it correct?-

if (expiryMonth == "MM" || expiryMonth == "mm") {
+6  A: 

Yes, that's correct. MDC (Mozilla Developer Center) has plenty of information about logical operators.

Tim Down
A: 

You could eliminate the need for the or statement and just set expiryMonth to lowercase.

expiryMonth=expiryMonth.toLowerCase(); // You can also use toUpperCase();

Then run your if statement.

jhanifen
That's not equivalent: "Mm" and "mM" will then satisfy the new condition but not the original.
Tim Down
This doesn't address the OP's question at all...
md5sum
+5  A: 

Yes, that's correct. You may be able to avoid the use of || in this situation by using the toLowerCase() or toUpperCase() method on strings:

if (expiryMonth.toLowerCase() == "mm") {

or

if (expiryMonth.toUpperCase() == "MM") {

Of course, this would also match Mm and mM, as Tim points out in the comments.

Andy E
Andy, that is much simpler then mine below. thanks
jhanifen
That's not equivalent: "Mm" and "mM" will satisfy the new condition but not the original.
Tim Down
@Tim: in which case, it might be better for him.
Andy E