newbie help with conditional statement

S

Sande

I haven't used JavaScript in awhile and am trying to practice. I'm
having trouble getting a very simple conditional statement to work. The
Netscape JavaScript Console is telling me that "If is not defined". But
it looks to me as if it is defined and a similar statement adapted from
a script I found on the web does work. Could someone tell me what I'm
missing?

This script doesn't work. Note that I attempted to use this on the 28th,
so it should have evaluated as true.

var cDate=new Date();
If (cDate.getDate() == 28)
{
document.write ("Winter is not a season, it's an
occupation. Sinclair Lewis");
}
Else
{
document.write ("The condition did not evaluate
to 'true'.");
}

But when I tried, the following (running it before noon), it did work:

if (cDate.getHours() < 12)
{
document.write("Good Morning");
}

Thanks,
Sande
 
D

David Dorward

Sande said:
I haven't used JavaScript in awhile and am trying to practice. I'm
having trouble getting a very simple conditional statement to work. The
Netscape JavaScript Console is telling me that "If is not defined".

Becuase it should be "if" not "If" - case sensitive.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top