I’m sure this is a simple answer, I just can’t figure it out!
I need to check whether a variable is equal to multiple things:
if ((dls == '10:0') && (dls == '10:3') && (dls == '11:0') && (dls == '11:3')){
stamp = 'PM';
};
Test Page: http://pmf.v5.cloudsvr.com.au/-artists/axle
You’ll see the alert firing, and DLS == 11:3 in the alert, but stamp still equals AM not PM.
Thanks for any help.
*EDIT: I was using the wrong operators! *
if ((dls == '10:0') || (dls == '10:3') || (dls == '11:0') || (dls == '11:3')){
stamp = 'PM';
};
You want
||operator,Your condition will not be true as using &&The if statement with && requires all the given conditions to be true which means dls should have 10:0, 10:3, 11:0 and 11:3 values in variable at a time but variable can have one of those at a time.Change
To