













































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














































During the last lecture we discussed Mathematical Methods
Mathematical Functions in JavaScript
Properties
Math.PI
Math.E
Math.LN
Math.LN
Math.LOG2E
Math.LOG10E
Math.SQRT
Math.SQRT1_ 5
Note the CAPITAL lettering of all properties
sin( r ), cos( r ), tan( r )
Standard trigonometric functions
Returns the sine, cosine or tangent of ‘r’, where ‘r’ is specified in radians
document.write( Math.cos( Math.PI / 4 ) )
7
asin( x ), acos( x ), atan( x )
Standard inverse-trigonometric functions
Returns the arcsine, arccosine or arctangent of ‘r’
in radians
document.write( Math.asin( 1 ) )
8
10
Returns Math.E raised to the power x
exp( x )
Returns the the natural logarithm of x
log( x )
Math.E → 1
ceil( x )
11
Returns integer nearest to x
Returns largest integer that is less than or equal to x
Returns smallest integer that is greater than or equal to x
round( x ) floor( x )
13
Returns the smaller of x and y
min( x, y )
Returns the larger of x and y
max( x, y )
random( )
14
Returns a randomly-selected, floating-point number between 0 and 1
document.write( Math.random( ) )
Today’s Goal (String Manipulation)
String Manipulation Examples
Example
name = “BHOLA” ;
document.write( “The length of the string ‘name’ is ”, name.length ) ;
19
The length of the string ‘name’ is 5