Click to See Complete Forum and Search --> : identical code, but one dosen't work Why???


Toka
08-10-2003, 09:53 AM
Hi,

I am new to javascript and am working through a tutorial, but I have written a piece of code identical to that in the tutorial but mine dosen't work. I have checked i haven't missed anything and that it is identical.

To all you on here it is a very small, and very simple piece of code. Please could someone put some light on this.

Code1. This works:-

<html>
<body>

<script type="text/javascript">
var d = new Date()
var time = d.getHours()

if (time < 17)
{
document.write("<b>Good morning</b>")
}
</script>

<p>
This example demonstrates the If statement.
</p>

<p>
If the time on your browser is less than 17,
you will get a "Good morning" greeting.
</p>

</body>
</html>


Code2. This dosen't work:-

<html>
<body>

<script type="text/javascript">
var d = new Date()
Var time = d.getHours()

if (time < 17)
{
document.write("<b>Good morning</b>")
}
</script>

<p>
This example demonstrates the If statement.</p>

<p>If the time on your browser is less than 10, you will get a "Good morning" greeting.
</p>

</body>
</html>

Anyone any idea's, or have I just missed something out and am going Blind

Thanks

Charles
08-10-2003, 10:10 AM
JavaScript is case sensitive and it's "var" and not "Var". And don't waste your time trying to learn JavaScript from a turtorial. At the end of the day you wont even know that you don't know the language. Instead read cover to cover and several times JavaScript : The Definitive Guide by David Flanagan (http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=2UVBZPJIV9&isbn=0596000480&itm=1).