Lewcid.com
Site-Cube

(this Subject)
#Editors
(this Time)
#10/23/2003
(this Place)
other/
(this Lewey Geselowitz)

 

Easy JS

Need to code a quick algorithm to find a number? Don't feel like firing up your massive IDE just to write 3 lines of code? Why not used your browser's built in JavaScript interpreter! Thats exactly what this page does, simply type your code into the boxes provided, press the button and a new page is created which lets you quickly execute your code.

This is great for those times when you want to write a short function but are on a computer without a compiler. JavaScript is a great C-syntax-family language and lets you get the job done quickly and easily. There are examples below the main work area, and a fuller explanation of how this page works, if your interested in how JavaScript itself works, there are many greats sites out there (most of them deal with it for use in web page creation, here I'm using it as just a simple scripting language). I hope you enjoy this little tool. Technical note: Easy JS simply creates a webpage with your code on it and gives it to your browser to display. This is all done locally (i.e. no server side involvement) so you can copy this page to your computer and use it there if you like. All interpreting, processing, garbage collection, etc. is done by your JavaScript interpret, my code just hands stuff over to it, so I shouldn't really get any credit.

Code Interpreter

Write any neccasary auxilary functions here:


Write the code that will go into your main function here:


Include standard Math functions so you can write sqrt instead of Math.sqrt. Also includes: sin, cos, tan, acos, asin, atan, log, exp, ln, floor, ciel, round, rand, pow, pi and e.


Equation Evaluator


Variable Name:Value


WARNING: Don't use the ^ (carrot looking thingy) to mean the exponent operator. This has a very different meaning in JavaScript. Instead use the pow function, which works like this: instead of writing 2^3, you write pow(2,3)

Note: You can use engineering notation. So you can write 5E5 or 6.23E-3 to mean 5*10^5 and 6.23*10^-3 (respectively).

Note: Although the above acts like a normal computer algebra system, it is infact merely convering whatever you write into JavaScript and then interpreting it. Also note that you can use in your expressions any functions you defined in the function area above (just not anything in main).



Examples

Here are a few examples to get you going with JavaScript, just click on the button and the code will be entered into the boxes above.
NOTE: These are very simple examples, don't expect perfect (or even good) code.
- uses Easy JS's special WriteLine function
- uses the JavaScript 'alert' function.
- As you would imagine.
- Asks for A, B, C in A*x^2 + B*x + C = 0, and the solves for real values of x. No imaginary.
- Shows the number of letters and words in any text entered in the 'Input' section. Very crude, words=number of spaces+1. 'Run (Multiple)' mode only!

Explanation

This is just a simple little tool that lets you code quick algorithums from anywhere. I often find that I'm in class, or at someones house, and the best way to solve something is with a little code, but this can be a tricky to do as most people don't have a compiler installed. So this page gives you an on-the-go compiler using good old JavaScript running on your computer (it is not server side executed). Just type in your code above, hit the button and you get your results. Here is an explanation of the two different 'Run' buttons.

Run (Single) - Creates a new page and automatically runs the code
Run (Multiple) - Creates a new page with a button on it, click the button and it executes the function you wrote above. This also allows you to run the code multiple times without refreshing.

In both modes you can use the special Write and WriteLine functions which output text to a console looking thing above. Also the GetLine function gets whatever input is in the input area. This is great if you just need to get some quick output. Of course you can also just use the 'alert' or whatever functions from JavaScript.

I wrote this page pretty quickly one day, and it's really just here as a convenience to me, if you find it useful that's great. If you have any questions for comments, send me an email at lewey@lewcid.com.