|
Taking a Class in JavaScript: How do you test your code?
Hey ALL
I just started taking a class that teaches the basics of writing JavaScript. I'm in the first chapter of the book, Problem-Solving with JavaScript, 1st Edition by Addison. I have read bad reviews of this book, that much of the code that is referenced is outdated, then again I've heard that many are bad that cover JavaScripting, except for the one that has a Rhino on the cover (I forget the name).
Apparently this book just covers writing JavaScript (at least in the 1st chapter) because it does not discussed how to run the programs after you create them. With that, I have no idea how to test my beginners code. It informs you to open notepad, and save the code as a text file. Now this can't be right, as I know text is not executable.
I'm using Notepad++ and it gives you the option to run from your browser, but doing that only displays the file contents. I tried saving it as a .js and launching it again in the browser, but same thing, just displayed the contents of the file.
Executing it from Windows 7, using Windows Scripting, generates a scripting error at Line 7, Char 9, Expected ';' Code 800A03EC. This is line 7:
Declare Numeric totCust // total Customers
I verified the syntax of the line to be correct from the book, so either Windows Scripting Host does not agree with it or maybe it's true, the JavaScript the book is teaching is outdated.
To be honest I have no idea, that's why I'm posting.
Thanks
Mike
Update:
I tried running it by including it in a html file and the JavaScript still did not execute. I only know basic html, but this syntax should be correct. Should note that the html does run, as the Testing JavaScript is displayed in my browser.
<html>
<head>
Testing JavaScript
<script type="text/javascript" src="F:\PortableApps\Notepad++Portable\customerStats.js"></script>
</head>
</html>
Last edited by Modify_inc; 01-12-2013 at 09:10 PM..
|