Javascript Calculator

While working on a side project, for which I found a small amount of time to work on. I created this rather simple and basic calculator, made with jQuery (Of course).

You can view the calculator here: jQuery Calculator

It was rather simple to build, and I don’t even think that the source is really worth describing or going into detail with.  The only thing I think is worth mentioning is the use of the ‘eval’ function, which allowed me to dynamically create javascript on the fly and take the result of it.

In this case, I passed in the Left and Right values along with the operator and simply stored the output.  For example, if you typed in “55”, hit “+” and then entered “100”.  I simply call:

[javascript]
var result = eval(’55’ + ‘+’ + ‘100’);
[/javascript]

Which resulted in the numeric value of 155, of course.

Leave a Reply