

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!


Math.random Math.floor
e.g., a single call to Math.sqrt replaces the underlying complex algorithm
the code from the button is moved to the user-defined Greet function as a result, the button is greatly simplified
GENERAL RULE: if more than one statement is to be associated with a button, define a separate function
in modern life, we are constantly confronted with complexity we don't necessarily know how it works, but we know how to use it e.g., how does a TV work? a car? a computer?
to use a TV/car/computer, it's not important to understand the inner workings we ignore unimportant details and focus on those features relevant to using it e.g., TV has power switch, volume control, channel changer, โฆ
parameters local variables return statements
parameters appear in the parentheses, separated by commas
if require some temporary storage in performing calculations, then declare local variables using the keyword var, separated by commas a local variable exists only while the function executes, so no potential conflicts with other functions
consists of the keyword return followed by a variable or expression