Textbook Notes (362,755)
United States (204,198)
Chapter 7

# Chapter7.docx

2 Pages
99 Views

School
Marist College
Department
Computer Science
Course
CMPT 120L-115
Professor
Matthew Johnson
Semester
Fall

Description
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

OR

Don't have an account?

Join OneClass

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

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.