{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Day 3

Day 3 - Obje(contd cts Day 3 Javascript Math Object...

This preview shows pages 1–8. Sign up to view the full content.

Objects (contd..) Day 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Javascript Math Object The built-in Math object includes mathematical constants and  functions. You do not need to create the Math object before  using it. To store a random number between 0 and 1 in a variable called  "r_number": r_number=Math.random() To store the rounded number of 8.6 in a variable called  "r_number": r_number=Math.round(8.6)
Math Object Methods Methods are invoked by lines like "Math.sin(1)". abs(a) - Returns the absolute value of a. The result value is 23 in the example below. resultval = Math.abs(-23) acos(a) - Returns the angle in radians that has a cosine of the passed value. The value of "resultval" is 90 degrees. resultval = (180/Math.PI) * Math.cos(0) asin(a) - Returns the angle in radians that has a sine of the passed value. The value of "resultval" is 90 degrees. resultval = (180/Math.PI) * Math.sin(1) atan(a) - Returns the angle in radians that has a tangent of the passed value. The "resultval" will be almost 90 degrees. resultval = (180/Math.PI) * Math.atan(100)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Math Object Examples Round.html Round2.html MathEg.html
Javascript String Object Various ways of Declaring String Object var myString = new String(); myString = "This is a string"; var myString = new String ("This is a string"); var myString = "This is a string"; Example: String.html

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
String Properties and Methods Properties: Length : length of the string Methods: Anchor:Creates a named anchor (hypertext target) big :Sets text to big  Blink:Sets text to blinking  bold :Sets text to bold
charAt:Returns the character at a specified position  fixed :Sets text in fixed-pitch font  fontcolor :Sets the font color  fontsize :Sets font size  indexOf:Returns the first occurrence of character x

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern