<BODY>
<SCRIPT type="text/javascript">
/*...x <== I've never seen this before...*/
dothis = new Date()
month = dothis.getMonth()
month = (month * 1) + 1
day = dothis.getDate()
year = dothis.getFullYear()
/*document.wrte(" ",month,"/",day,"/",year," ") <== mispelled write*/
document.write(" ",month,"/",day,"/",year," ") // CORRECTED LINE
</SCRIPT>
</BODY>
|
|
The answer: The script is supposed to display today's date, although I didn't know that at first because the browser displayed a blank page with the original script. I encountered two errors, which is what I was supposed to do. However, the Developer's Console only shows one error at a time, which sucks! I only used Firefox to debug the script. The first report was "SyntaxError: expected closing parenthesis, got identifier", pointing me to the "dothis = new Date()" line, which is just below the "...x" (the author had stuck that in for fun). Once I commented out the "...x" line, I ran the Console again and Firefox then reported a new error "TypeError: document.wrte is not a function", and pointed me to that line.
What I have learned:
- Rerun the Console after each error you fix
- If the browser doesn't understand something, it might think the next line is the error
- If you google long enough, you will find what you are looking for