The script editor is suitable for simple scripts. For more complicated scripts, you will need a JavaScript Debugger to allow you to step through the script and inspect variables. Fortunately, there are many free JavaScript Debuggers available including, but not limited to, most desktop browsers.
This is a list of guides for using Safari, Firefox and Chrome debuggers:
Below are links to HTML pages that can be used to debug scripts on a desktop browser.
Follow the link to the page.
Safari is used to develop the CALC 1 JavaScripts since they both use JavaScriptCore. But any modern debugger should work fine.
These debugging pages use Test-Driven Development.
The cycle is:
When done, save the HTML file for future reference and in case you find a bug later.
If you find a bug, don't fix it until you write a test to reproduce the bug. Then fix the bug. Your previous tests will confirm that the changes to fix the bug did not cause other tests to fail.