2 Pages
Unlock Document

Marist College
Computer Science
CMPT 120L-115
Matthew Johnson

A Balanced Introduction to Computer Science, 3 Edition David Reed Chapter Seven: Functions and Randomness A. Predefined JavaScript Functions 1. Functions are identified by name with the inputs to the function paced in parentheses a. A unit of computational abstraction b. Example: to convert a string to its corresponding number, add parseFloat function and obtain value c. Calling – applying a function to inputs i. Return value – output of the function ii. Example: amount=parseFloat(document.getElementById(‘amoun tBox’).value); 2. Math Functions a. Prefix is Math. i. Signifies that functions are a part of a library of mathematical routines ii. Example: Math.sqrt (gives square root) Math.max (gives largest of 2 inputs) 3. Raising Numbers to a Power 3 a. Math.pow (2, 3) returns 2 =8 i. Can include negative exponents 4. Generating Random Numbers a. A function is a mapping from some number of inputs to a single output b. Math.random has no inputs i. Pseudorandom results: the function uses an algorithm to generate seemingly random values from within the
More Less

Related notes for CMPT 120L-115

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.