Javascript Question

How to do a three conditions are true ELSE IF statement in Javascript?

else if ((month == "November" && day== "7") && (year > "2016")){

What is the correct way to check that the month is November, the day is the 7th and the year is more than 2016, (without using || if possible?)

Answer Source

The way you've done it is fine, although you don't need the inner ():

else if (month == "November" && day== "7" && year > "2016"){

And it's a bit odd you're using strings for the day and year, you might want to double-check that. If year is really a string, you'll have the problem that year > "2016" will be false for various year values (such as "90", because any string starting with a 9 is "greater than" any string starting with a 2) because you're doing a string comparison rather than a numeric one).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download