Web Analytics Made Easy -
StatCounter if... else... - CodingForum

Announcement

Collapse
No announcement yet.

if... else...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • if... else...

    I am trying to make the date display with the correct day suffix.

    Each of the items below will work alone

    i.e. if (daym=1||daym=21||daym=31)
    daym=daym+"st"

    ...but the following is obviously syntactically incorrect:

    if (daym=1||daym=21||daym=31){
    daym=daym+"st"}
    else if (daym=2||daym=22){
    daym=daym+"nd"}
    else if (daym=3||daym=23){
    daym=daym+"rd"}
    else if (daym>3&&daym<21){
    daym=daym+"th"}
    else if (daym>23&&daym<31){
    daym=daym+"th"}

    Can someone show me why?

    Thanks
    The difference between genius and stupidity is that genius has its limits. (Albert Einstein)

  • #2
    You need to use == not = since you are comparing. Using the = sign by itself is just assigning a value to the day variable.
    if(day==1 || day==21 || day==31)
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment

    Working...
    X