Enter a JavaScript expression:





Simple example:
5*(3+4)-6
when entered in the text box, evaluates to 29

Javascript routines, as well as expressions, can be evaluated.

For example, the following code:
a = 0
for (i=0; i<10; i++) {
a = a + i
}
return a
when entered in the text box, evaluates to 45

Math functions must be preceded by "Math."
JavaScript supports the following math functions:
Math.abs(a)     // the absolute value of a
Math.acos(a)    // arc cosine of a
Math.asin(a)    // arc sine of a
Math.atan(a)    // arc tangent of a
Math.atan2(a,b) // arc tangent of a/b
Math.ceil(a)    // integer closest to a and not less than a
Math.cos(a)     // cosine of a
Math.exp(a)     // the constant e raised to power a
Math.floor(a)   // integer closest to and not greater than a
Math.log(a)     // log of a base e
Math.max(a,b)   // the maximum of a and b
Math.min(a,b)   // the minimum of a and b
Math.pow(a,b)   // a to the power b
Math.random()   // pseudorandom number in the range 0 to 1
Math.round(a)   // integer closest to a 
Math.sin(a)     // sine of a
Math.sqrt(a)    // square root of a
Math.tan(a)     // tangent of a

Math constants are:
Math.E		// base of the natural log system
Math.LN10	// natural log of 10
Math.LN2	// natural log of 2
Math.PI		// pi
Math.SQRT1_2	// square root of 1/2
Math.SQRT2	// square root of 2
Example:
Math.sin(Math.PI/2)
Evaluates to 1

Here are a few string functions, where "str" = name of your string:
str.length		// returns length of str
str.charAt(x)		// returns the character at position x
str.indexOf(x,y) 	// returns the first occurrence of character x starting from position y 
str.lastIndexOf(x,y)	// returns the last occurrence of character x starting from position y 
str.substring(x,y)	// returns a portion of a string, from character x to character y
str.toLowerString()	// converts a string to lowercase 
str.toUpperString() 	// converts a string to uppercase 
Example:
s = "applebanana"
len = s.length
sub = s.substring(3,10)
gives results len = 11, sub = "lebanan"

Here is an example of a routine to invert a string
str = "applebanana"
len = str.length
strout = ""
for (var i=len-1; i>=0; i--) {
strout=strout + str.charAt(i)
}
return strout